slm7pg
Last Updated: February 25, 2016
·
1.003K
· kennu
F8828772ff141a7cb8fe109af7948da1

Use pgrep and pkill instead of grepping ps output

Linux provides two handy commands for enumerating and signaling processes:

pgrep - look up processes by name and arguments (regexp)

pkill - send signals to processes with same criteria

So, instead of grepping and parsing the output of "ps aux", you can just type something like this to find the PID of the process you are looking for:

pgrep -f '[p]uppet agent --onetime'

And then, use the same options with pkill to send the signal.

Say Thanks
Respond
Filed Under