Tag Archives: grep

Killing specific processes with ps, grep, awk and xargs

Often when you work with Linux you need to kill a bunch of processes matching a certain pattern. This could be accomplished using ps, grep, awk and xargs like this:

ps -aux |grep php-fpm |grep -v grep | awk '{print $2}' | xargs kill

If the process won’t die you could add -9 to kill which can’t be blocked by anything. Of course you need to own the processes you try to kill (or use sudo).

References:
Article on commandlinefu.com