bash - how to extract the PID of a process by command line -


i want pid of process namely "cron" command line. tried following script.

ps ax|grep 'cron' 

but getting part of table,

   1427 ?        ss     0:00 /usr/sbin/cron -f 24160 pts/5    s+     0:00 grep --color=auto cron 

how extract pid ?

just use pidof, rather use other commands , apply post-processing actions on them.

$ pidof cron 22434 

to make command return 1 pid pertaining to process, use -s flag

-s single shot - instructs program return 1 pid.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -