• Linux 批量杀掉进程


    使用awk批量杀进程的命令:

    ps -ef | grep firefox | grep -v grep | awk '{print "kill -9 "$2}'|sh
    #列出了当前主机中运行的进程中包含firefox关键字的进程
    ps -ef | grep firefox | grep -v grep    
     
    #列出了要kill掉这些进程的命令,并将之打印在了屏幕上 
    ps -ef | grep firefox | grep -v grep | awk '{print "kill -9 "$2}'
     
    #后面加上|sh后,则执行这些命令,进而杀掉了这些进程
    ps -ef | grep firefox | grep -v grep | awk '{print "kill -9 "$2}' | sh

    使用cut批量杀进程的命令:

    ps -ef | grep firefox | grep -v grep | cut -c 9-15 | xargs kill -9
    #列出了当前主机中运行的进程中包含firefox关键字的进程
    ps -ef | grep firefox | grep -v grep 
          
    #截取第9至15字符(进程id),列出了要kill掉这些进程的id,并将之打印在了屏幕上
    ps -ef | grep firefox | grep -v grep | cut -c 9-15 
     
    #后面加上'xargs kill -9'后,则执行这些命令,进而杀掉了这些进程
    ps -ef | grep firefox | grep -v grep | cut -c 9-15 | xargs kill -9

    转载:https://www.cnblogs.com/abeen/p/11080841.html

    Talk is cheap, show me the code.
  • 相关阅读:
    java 字符串截取
    字符编码Unicode-正则表达式验证
    APP数据加密解密
    ThreadLocal线程局部变量
    用Eclipse进行远程Debug代码
    JPA对应关系
    JPA名称规则
    dubbo环境搭建
    历史表更新数据
    api加密算法
  • 原文地址:https://www.cnblogs.com/cidgur/p/12029734.html
Copyright © 2020-2023  润新知