Kill Process by Name

#!/bin/bash
# reads search term from the commandline then finds and kills all related processes.
# remove the comment from the kill line to activate kill function
#
# another dangerous toy by Elmars
# v.1 17 oct 2011

ps -aux | grep $1 |
while read line
do
echo $line
PID=`echo $line | awk '{print $2}'`
#       echo $PID
#kill -9 $PID
done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s