#!/bin/sh NAME='shell.php' 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 "---------------"
1),将之保存为killprocess.sh
2),调用./killprocess.sh programmename。其中programme可以为程序名字,也可以是启动程序时的命令行,只要能在ps -ef | grep programmename 之后出现所有的该程序对应的进程即可