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.
Written by Kenneth Falck
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Linux
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#