【一练】杀死指定进程

上一篇 / 下一篇  2018-01-15 16:33:40 / 个人分类:shell

>> cat kill_process.sh 
#!/bin/bash
if [ $# -lt 1 ] 
then
   echo "缺少参数!"
   exit 1
fi

process=`ps -ef|grep $1|grep -v grep | grep -v PPID |awk '{print $2}'`
for i in $process
do 
   echo "kill the $1 process [ $i ]"
   kill -9 $i
done

>>  ./kill_process.sh top
kill the top process [ 3152 ]
kill the top process [ 3154 ]



TAG:

 

评分:0

我来说两句

Open Toolbar