Linux – Look for a process with a given name

linuxps

I am trying to convert the VMS command show/system/process=processname into an equivalent Linux command.

I tried the following but it returned none of the processes:

ps -C /exeimages/processname.pl  

Best Answer

ps -C looks for an exact match of the basename of the executable at the time if was executed. So, in this case, ps -C perl or ps -C processname.pl would more likely be what you want. What matters is what you find in /proc/<pid>/stat.

If you want to match on the command line (the concatenation of the arguments of the command including argv[0]), you can use pgrep -f as found on Solaris, recent Linux and most BSDs.

Related Question