效果:

运行命令:

./killallphpjavarm.sh java

源码:

#!/bin/sh
#根据进程名杀死进程
#FileName: killjavaphprm.sh

pgrep php

killall php

rm log*

if [ $# -lt 1 ]
then
echo "缺少参数:procedure_name"
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

 

posted on 2016-08-10 16:58  阚壠  阅读(537)  评论(0编辑  收藏  举报