inside the mind of a linux admin

simple foreach to kill multiple PIDs

Sometimes you’ll find a bunch of stale or malicious processes that need to be killed. When a killall won’t grab them, use this simple for loop to kill -9 each of them individually from the ps output. Simply replace the name= variable with the PID’s name or a string from the process list.

# name="perl"
# for i in $(ps afx|grep $name|awk {'print $1'}) ; do kill -9 $i ; done

The example above would kill all running processes that had the word “perl” in the command.

Related Posts

synergy: How to enable crypto (encryption) and generate SSL certificate

The newer Linux versions of the popular mouse/keyboard sharing application “synergy” now has built in encryption. Here’s how to configure it: Just simply passing the –enable-crypto flag on your synergy server without having a proper SSL certificate will result in the inability to connect to clients and generate an error message similar to this in […]

Read More

Change Number Pad Delete (dot) key from a comma in Ubuntu Linux

I recently purchased a new keyboard and updated to the latest Ubuntu, I’m also an avid user of the number pad for quick input when dealing with spreadsheets or accounting. I found that my num pad’s delete key (“.”) was outputting a comma (“,”) instead. Pretty annoying? I agree, but this can be very easily […]

Read More

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.