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
Post a Comment