How can I find out what the program file name is for a running process?
|
|
The following run from a shell will give you the command, its full path, and its invocation arguments all in the last column for all running programs:
This is the unix syntax, since you were not specific. There is also GNU and BSD syntaxes available in linux. |
|||
|
|
|
Note that all of the above commands will only work some of the time. For example, here the output of "ps" shows the path to a program, but if you try to access that path you find that nothing is there:
In fact, the value displayed by ps is entirely up to the whatever code launched the program. For example:
So basically, you can't rely on the output of ps. You might be able to rely on
But even in this case the file may no longer exist. |
|||
|
|
How about something like this.
man lsof
|
|||
|
|
|
if your programs reside deeply in a /usr/local/program/bin filesystem tree it is possible on a limited terminal not to see the full path and program. you can use:
to see the full unlimited command line which belongs to all the processes. Out of the ps manpage:
|
||||
|
|
|
On Linux it's very simple:
Don't parse anything until you're sure there's no other way. Cheers! :) |
|||
|
|