如何杀死正在运行的python进程? [重复]

时间:2022-05-27 22:23:23

This question already has an answer here:

这个问题在这里已有答案:

How to kill a running python in shell script when we know the python file name xxx.py? (it is executed by cmd python xxx.py)

当我们知道python文件名xxx.py时,如何在shell脚本中杀死正在运行的python? (它由cmd python xxx.py执行)

I can use ps aux | grep python to get the pid of it. and then kill pid to terminate it.

我可以使用ps aux | grep python来获取它的pid。然后杀死pid以终止它。

but every time, I have to execute two cmd. Is there a good way to do it?

但每次,我都要执行两个cmd。有没有好办法呢?

1 个解决方案

#1


55  

The pkill utility can look at command lines when sending signals:

pkill实用程序可以在发送信号时查看命令行:

pkill -f xxx.py

#1


55  

The pkill utility can look at command lines when sending signals:

pkill实用程序可以在发送信号时查看命令行:

pkill -f xxx.py