kill all java php rm.sh

时间:2022-04-17 00:16:42

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

#查看php进程ID
echo "php进程ID:"
pgrep php

#杀死所有php进程
echo "杀死所有php进程"
killall php

#删除log日志文件
#echo "删除所有以log开头的日志文件"
rm log*

echo "显示文件"
ls

#杀死传入的进程名
echo "杀死传入的进程名称对应的ID:"
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