码迷,mamicode.com
首页 > 系统相关 > 详细

Linux 下根据进程名kill进程

时间:2016-04-25 19:30:41      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

脚本方式实现:

#!/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

命令形式实现:

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

 

Linux 下根据进程名kill进程

标签:

原文地址:http://www.cnblogs.com/lx823706/p/5432155.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!