簡體   English   中英

如何殺死一個進程,而所有進程都是Linux?

[英]How to kill one process and it's all child process Linux?

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))

例如,通過ID殺死該進程:使用此命令列出您的python文件ps -A| grep python ps -A| grep python並殺死進程: kill 27913

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM