How kill several subprocesses with the same name, with Python3

54 Views Asked by At

With Raspberry Pi and Python3 I get these subprocess:

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

I need kill all python3 blue.py (from Python) and get...

ps -aux | grep python3

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

There are 1 best solutions below

0
sirmagid On

for centos7 i use

pkill -f "Process name"

enter image description here