Category Archives: Linux Tip of the Week

Matt Palmers Linux Tip of the week – Process kill one-liner

I found this pretty handy to kill off processes, without having to specify the PIDs,etc

kill -9 `ps hauwwx|grep <username/process runner eg:mysql>|grep -v grep root|awk ‘{ print $2 }’`

what it will do is match the username (if found) in the grep and exclude the root user. The awk statement provides the kill command with the second field from the processlist as displayed by grep, and substitutes it as the PID(s).

This saves you having to match multiple PIDs if different users are running the same program for example, but you want to kill off every instance of a program you can do it all from one place, and in one go.