kill a process by name on Linux

November 23rd, 2010 by xrigher Leave a reply »

Way 1: find the pid of the process and then kill it by pid.

Step 1: How to find pid:
$> ps aux | grep amsn
output:

weiping 7208 0.4 2.2 260684 86808 ? Sl 09:22 0:15 wish8.5 /usr/bin/amsn weiping 7804 0.0 0.0 8952 876 pts/10 S+ 10:15 0:00 grep amsn

or
$> pidof wish8.5
output:

7208

Step 2: Kill the process
$> kill 7208

Way 2: use killall

killall -9 wish8.5

Way 3: use pkill

pkill wish8.5

Way 4: use ps + kill

export sspid=`ps aux | grep wish8.5| awk 'NR==1{print $2}' | cut -d' ' -f1`;kill $sspid

Advertisement

Comments are closed.