On SunOS there is pargs
command that prints the command line arguments passed to the running process.
Is there is any similar command on other Unix env
You can use pgrep
with -f
(full command line) and -l
(long description):
pgrep -l -f PatternOfProcess
This method has a crucial difference with any of the other responses: it works on CygWin, so you can use it to obtain the full command line of any process running under Windows (execute as elevated if you want data about any elevated/admin process). Any other method for doing this on Windows is more awkward ( for example ).
Furthermore: in my tests, the pgrep way has been the only system that worked to obtain the full path for scripts running inside CygWin's python.
Another variant of printing /proc/PID/cmdline
with spaces in Linux is:
cat -v /proc/PID/cmdline | sed 's/\^@/\ /g' && echo
In this way cat
prints NULL characters as ^@
and then you replace them with a space using sed
; echo
prints a newline.
On Solaris
ps -eo pid,comm
similar can be used on unix like systems.
You can simply use:
ps -o args= -f -p ProcessPid
For Linux & Unix System you can use ps -ef | grep process_name
to get the full command line.
On SunOS systems, if you want to get full command line, you can use
/usr/ucb/ps -auxww | grep -i process_name
To get the full command line you need to become super user.
pargs -a PROCESS_ID
will give a detailed list of arguments passed to a process. It will output the array of arguments in like this:
argv[o]: first argument
argv[1]: second..
argv[*]: and so on..
I didn't find any similar command for Linux, but I would use the following command to get similar output:
tr '\0' '\n' < /proc/<pid>/environ
Rather than using multiple commands to edit the stream, just use one - tr translates one character to another:
tr '\0' ' ' </proc/<pid>/cmdline