You're viewing a comment by s@my and its responses.

s@my Permalink
June 08, 2010, 17:14

Very nice, but you should eliminate the process that contain grep:
kill -9 $(ps -ef|grep search_string|grep -v grep|awk -F " " '{ print $2 }')

Comment Responses

Pablo Permalink
June 23, 2010, 01:39

You can do it without grep too:

kill -9 $(ps -ef | awk '/search pattern/ { print $2 }')

And to avoid errors if nothing is found:

ps -ef | awk '/search pattern/ { print $2 }' | xargs -r kill -9

beli Permalink
May 03, 2012, 12:40

instead of "grep -v grep" you can also use "grep [s]earch_string" so the full line would look like:

kill -9 $(ps -ef | grep [s]earch_string | awk -F " " '{ print $2 }')

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the word "sandbox_195": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.