如何杀死一个进程,而所有进程都是Linux?

时间:2019-07-29 08:10:24

标签: linux shell

user1    27913 41004  4 15:54 pts/202  00:00:02 python demo.py
user1    31916 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31917 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31918 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31919 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31920 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31921 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31922 27913  0 15:55 pts/202  00:00:00 python demo.py
user1    31923 27913  0 15:55 pts/202  00:00:00 python demo.py

有一个进程27913,我想杀死它及其所有子进程,如何使它起作用?

  

更新python脚本:

下面是我的demo.py

from concurrent.futures import ProcessPoolExecutor
import time

def foo(num):
    time.sleep(0.5)
    print(num)


if __name__ == "__main__":
    while True:
        with ProcessPoolExecutor(max_workers=8) as exe:
            exe.map(foo, range(1,4))

1 个答案:

答案 0 :(得分:2)

通过其ID杀死进程 例如: 使用此命令列出您的python文件ps -A| grep python 并终止进程:kill 27913