根据进程名字获取id并kill

#!/bin/sh

NAME=$1
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
echo "---------------"

 

posted @ 2015-12-10 15:01  fastwave2004  阅读(458)  评论(0编辑  收藏  举报