//View Tip #191
Similar Tips
» Concatenate pairs of lines
» Version all unversioned files in an SVN checkout
» Subtract one file from another
» See your favorite commands
» MAC address conversion


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
ps | grep processName | grep -v grep | awk '{print "kill -9 " $2}' | sh

Take the '| sh' off the end before running to check the commands that will be run.

View Comments »


Add your comment

Comments are currently disabled
Not sure this even works. And it's poorly written. If you do this:
ps | grep bash | grep -v grep | awk '{print "kill -9 " $2}'

for example, you get this output:
kill -9 pts/2

because the output of
ps | grep bash | grep -v grep


14814 pts/2    00:00:00 bash

Which means you would need to do

ps | grep bash | grep -v grep | awk '{print "kill -9 " $1}'

to get the correct command. However this is poorly written and would be a lot nicer as:

ps -C processname -o pid= | awk '{print "kill -9 " $1}' | sh

and even that could be reduced a lot, I'm sure
Posted 2008-10-02 16:36:51
hey... try the following:

$ killall ProcessName

$ fuser -k `which ProcessName`
Posted 2008-10-25 18:08:29
Try to use pkill command. That's pretty ease
>$ pkill ProcessName
Posted 2008-10-25 21:10:39
ps ax | grep processName | grep -v grep | awk '{print $1}'|xargs kill -15

Soft kill
Posted 2009-08-05 09:28:36

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit