linux根据进程名字杀死进程

ps -ef | grep procedure_name | grep -v grep | awk '{print $2}' | xargs kill -9

Linux Shell脚本实现根据进程名杀死进程

#!/bin/sh
#根据进程名杀死进程
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 2017-09-21 19:46  Archmagel  阅读(1558)  评论(0编辑  收藏  举报

导航