linux - Linux下如何杀死一个进程及其所有子进程?

标签 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,我想杀死它及其所有子进程,我怎样才能让它工作?

update python script:

下面是我的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 并终止进程:kill 27913

关于linux - Linux下如何杀死一个进程及其所有子进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57249614/

相关文章:

linux - bash 获取硬件脚本输出到 .csv 文件

linux - 如何在 Linux 上查看和编辑临时端口范围?

python - 编写一个与 wpa_supplicant 交互的外部程序

c++ - cURL - Linux 上的 "hanging"套接字连接

bash - shell脚本中的这一行是做什么的?

linux - 用于计算已用时间的 Bash 脚本

linux shell kill信号SIGKILL && KILL

linux - 仅列出文件; iconv 和目录?

c++ - linux中的time_t类型是什么

linux - 如何在eclipse中打开tar.gz文件