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的进程,那么如何同时杀死多个进程呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
找到解决方法了:kill -9 $(ps -ef|grep -E 'aprogram|bprogram|c'|grep -v grep|awk '{print $2}')
killall -9 $i
真的很基础的东西。
pkill -f GetDeviceData.pykillall GetDeviceData.py
或者
pkill GetDeviceData.py
两个命令指定的进程名都可以是部分匹配,.py可以省略。