如何使用Python3杀死多个同名子进程

时间:2019-06-05 17:00:51

标签: shell kill-process pkill

使用Raspberry Pi和Python3,我得到了以下子过程:

ps -aux | grep python3

pi    4168  0.9  0.7  11088  7304 ?     S    18:31   0:00 python3 blue.py
pi    4175  1.2  0.7  11088  7300 ?     S    18:33   0:00 python3 blue.py
pi    4185  2.4  0.7  11092  7300 ?     S    18:35   0:00 python3 blue.py
pi    4195  6.5  0.7  11088  7300 ?     S    18:38   0:00 python3 green.py

我需要杀死所有 python3 blue.py (从Python )并获取...

ps -aux | grep python3

pi    4195  6.5  0.7  11088  7300 ?     S    18:38   0:00 python3 green.py

1 个答案:

答案 0 :(得分:0)

我使用centos7

pkill -f "Process name"

enter image description here