2

I want to use pgrep to find the pid of a process, e.g.

$ pgrep bluetoothd
441

However, the processes I need to search run within a wrapper called RunFIDProcess:

[cama@dc1-dev-lin-1204 tests]$ ps -ef | grep RunFIDProcess
tps        544     1  0 Dec13 ?        00:00:00 /bin/sh .//RunFIDProcess CASE_SJDI SJdi -c SJdi.auto.cfg -m PRIMARY_WARM
tps        546     1  0 Dec13 ?        00:00:00 /bin/sh .//RunFIDProcess CASE_ETH Eth -c Eth.cfg
tps        547     1  0 Dec13 ?        00:00:00 /bin/sh .//RunFIDProcess CASE_DBWEBSERVER DbWebServer
tps        556     1  0 Dec13 ?        00:00:00 /bin/sh .//RunFIDProcess CASE_TABLE_PROXY TableProxy -c TableProxy.cfg
cama      4519     1  0 07:30 ?        00:00:00 /bin/sh .//RunFIDProcess CASE_SJDI SJdi -c SJdi.auto.cfg -m PRIMARY_WARM
cama      4524     1  0 07:30 ?        00:00:00 /bin/sh .//RunFIDProcess CAMA_DS5_QRY DaqSvr -m cold -c cama_DaqSvr.DS5.cfg
cama      4530     1  0 07:30 ?        00:00:00 /bin/sh .//RunFIDProcess CAMA_US_OSUB Osub -c cama_Osub.US.auto.cfg -Cold
cama      4534     1  0 07:30 ?        00:00:00 /bin/sh .//RunFIDProcess CAMA_DS7_QRY DaqSvr -m cold -c cama_DaqSvr.DS7.cfg

So,

[cama@dc1-dev-lin-1204 tests]$ pgrep CAMA_US_OSUB

returns nothing.

How can I find a process by its name as well as its first command line argument?

  • 3
    pgrep -f CAMA_US_0SUB – user4556274 Dec 22 '16 at 20:56
6

The -f switch to pgrep allows it to search the full list of arguments to each process. You can therefore use pgrep -f CAMA_US_0SUB to search for anything with that used at its argument (or indeed processes with that name).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.