Wednesday, July 13, 2011

Kill multiple processes using awk command


If you wish to kill multiple instances manually executed in background or the running processes of crontab then you can kill them all without taking the headache of selecting process id of each process and giving command "kill -9 process id", so this command can do magic for you



ps -ef | grep "username or process name" | grep -v grep | awk '{ print $2 }' | xargs kill -9

This command will first check running process with specific username or process name than "grep -v grep" will exclude the row which contain the word grep in it after that awk command prints the second column of process id's and "xargs kill -9" will kill all the returned process id's associated with it.

Author:
Waqas Rafi

1 Comment:

Akhil said...

Nice Article.
Some examples on Find Command and Awk Command

Disclaimer: Independent operated blog, feed backs at kaxxi.khan@gmail.com
© copyright 2011 info-logy.blogspot.com