Friday, June 20, 2008

killps - Pipe /bin/ps to /bin/kill

Have you ever wanted to kill a bunch of processes? Here is how to do it:

1) Put this in your .bashrc

# Killps - Marky 2008-06-20
# usage: ps -ef | grep progname | killps
alias killps="awk '// { print \$2 }' | xargs kill"


2) Here's how to use it:

2.A) Search for the processes. Make sure you only see what you want to kill.
e.g.:
prompt%> ps -ef | grep program_name

e.g.:
ps -ef | grep username | grep program_name | grep -v grep

2.B) When you'r happy with the filter, pipe it to killps
e.g.:
prompt%> ps -ef | grep program_name | killps

e.g.:
ps -ef | grep username | grep program_name | grep -v grep | killps

Enjoy!

No comments:

Post a Comment