ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux批量杀掉进程linux批量杀掉进程

linux批量杀掉进程linux批量杀掉进程

原创 Linux操作系统 作者:season0891 时间:2010-07-23 22:30:24 0 删除 编辑
手动杀掉linux某程序进程委实麻烦,今天写了一个简单的脚本,可以批量杀掉程序进程。

rsync同步没有成功,会有很多进程堵住,ps axuw|grep rsync,看到有几十个进程挂着,看着不爽,决定杀之,写了个简单的脚本,如下(kill.sh):

  1. #!/bin/sh
  2. keys=`(ps -ef |grep "rsync" |grep -v "grep") | awk '{print $2}'`
  3. for key in ${keys[*]}
  4. do
  5.        kill -9 $key
  6. done

运行: sh kill.sh

ps -ef |grep "rsync" |grep -v "grep") | awk '{print $2} | xargs kill -9 
come from:http://blog.chinaunix.net/u3/104216/showart_2065070.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-668881/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-06-10

  • 博文量
    790
  • 访问量
    2098072