红联Linux门户
Linux帮助

如何批量kill进程

发布时间:2016-12-01 14:28:12来源:linux网站作者:周小Q
程序调试阶段可能会需要批量kill进程的情况。
 
1.如果所kill进程名称相同时
可用killall proc_name  
 
2.可利用进程号批量kill
ps -elf | grep response_sync_serv  
217:0 S d5000     8333     1  1  78   0 - 20290 run_in 12:17 pts/3    00:00:00 ./response_sync_serv realtime public test1_ser1_1 50001  
218:0 S d5000     8334     1  1  78   0 - 20290 run_in 12:17 pts/3    00:00:00 ./response_sync_serv realtime public test1_ser2_1 53001  
219:0 S d5000     8336     1  1  78   0 - 20290 run_in 12:17 pts/3    00:00:00 ./response_sync_serv realtime public test1_ser1_2 50002  
220:0 S d5000     8338     1  1  78   0 - 20290 run_in 12:17 pts/3    00:00:00 ./response_sync_serv realtime data_srv test1_ser3_1 56001  
221:0 S d5000     8339     1  0  78   0 - 20290 run_in 12:17 pts/3    00:00:00 ./response_sync_serv realtime scada test1_ser4_1 59001
 
ps -elf | grep response_sync_serv | awk '{print $4}'  
8333  
8334  
8336  
8338  
8339
 
ps -elf | grep response_sync_serv | awk '{print $4}' | xargs kill -9
 
本文永久更新地址:http://www.linuxdiyf.com/linux/26479.html