Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 如何使用Python3杀死几个同名的子进程_Shell_Kill Process_Pkill - Fatal编程技术网

Shell 如何使用Python3杀死几个同名的子进程

Shell 如何使用Python3杀死几个同名的子进程,shell,kill-process,pkill,Shell,Kill Process,Pkill,通过Raspberry Pi和Python3,我得到了以下子流程: ps-aux|grep蟒蛇3 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

通过Raspberry Pi和Python3,我得到了以下子流程:

ps-aux|grep蟒蛇3

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
pi    4195  6.5  0.7  11088  7300 ?     S    18:38   0:00 python3 green.py
我需要杀死所有的python3 blue.py(来自Python)并获得

ps-aux|grep蟒蛇3

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
pi    4195  6.5  0.7  11088  7300 ?     S    18:38   0:00 python3 green.py
我用了七个世纪

pkill -f "Process name"

对于centos7我使用

pkill -f "Process name"

你有权使用pkill吗?谢谢你,布拉德,我想pkill可以为我工作。os.system(“pkill-f'python3 blue.py')其他方式(终端):ps aux | grep-ie'python3 blue.py'| awk'{print“kill-9”$2}'| sh-xd您有权访问
pkill
?谢谢Brad,我认为pkill可以为我工作。系统(“pkill-f'python3 blue.py'))其他方式(终端):ps aux | grep-ie'python3 blue.py'| awk'{print“kill-9”$2}'| sh-x