Killing Processes

Previously if I had wanted to kill a bulk list of mysql processes I would have done something like:

ps auxww | grep ^mysql | awk '{print $2}' | xarg kill -9

Today I discovered two really handy commands that make listing and killing processes a lot easier, pkill and pgrep.

You can achieve the same result as above with:

pkill -9 -u mysql mysql

This will kill all processes owned by the mysql user that have mysql in their name.

← Back to Blog