linux shell如何同时杀死多个进程?


!/bin/sh

根据进程名杀死进程

PROCESS= ps -ef|grep GetDeviceData.py|grep -v grep|grep -v PPID|awk '{ print $2}'
for i in $PROCESS
do
echo "Kill the GetDeviceData.py process [ $i ]"
kill -9 $i
done

上面这段代码只能杀死 GetDeviceData.py的进程,那么如何同时杀死多个进程呢?

Linux shell

icemaze 9 years, 1 month ago

killall GetDeviceData.py
或者
pkill GetDeviceData.py

两个命令指定的进程名都可以是部分匹配,.py可以省略。

威廉-伯爵 answered 9 years, 1 month ago


 killall GetDeviceData

RachelC answered 9 years, 1 month ago

pkill -f GetDeviceData.py

傲娇的怪叔叔 answered 9 years, 1 month ago

killall -9 $i
真的很基础的东西。

KUICIK answered 9 years, 1 month ago


 killall

如此糟糕的猫 answered 9 years, 1 month ago

找到解决方法了:kill -9 $(ps -ef|grep -E 'aprogram|bprogram|c'|grep -v grep|awk '{print $2}')

Cnn木南 answered 9 years, 1 month ago

Your Answer