惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
U
Unit 42
WordPress大学
WordPress大学
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
博客园 - 叶小钗
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
V
V2EX
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - ABeen

[Database] Mongodb 分片集群 [Linux] vim状态栏配置 [Linux] Centos 添加开机启动脚本 [Linux] Docker 镜像及容器自动化思路 [Linux]Docker 容器时间与宿主机同步 [Linux] Tomcat java.lang.OutOfMemoryError: Java heap space [Linux] Nginx 反向代理配置 http headers 带下划线fields转发 [Linux] 非云环境的Ubuntu主机如何关闭Cloud-init [DataBase] MySql 查看实时日志 [Misc] ZSH 常用快捷键 [Database] MAC MySQL中文乱码问题 [Misc] python 开发vim 插件初步测试 [Tools] 多媒体视频处理工具FFmpeg [Linux] Ubuntu Server18 python3.7 虚拟环境 [Linux] 树莓派编译python3.7.4 [Linux] TMUX Python版本设置 arm树莓派Raspbian 下安装selenium+chrome 树莓派Raspbian系统密码 mac 终端查看端口命令
Linux 批量杀进程的命令
ABeen · 2019-06-25 · via 博客园 - ABeen

使用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