Linux 如何杀死正在运行的python进程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19541634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to kill a running python process?
提问by HenrySnoopy
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文件名时如何在shell脚本中杀死正在运行的python xxx.py?(它由 cmd 执行python xxx.py)
I can use ps aux | grep pythonto get the pid of it. and then
kill pidto terminate it.
我可以ps aux | grep python用来获取它的pid。然后
kill pid终止它。
but every time, I have to execute two cmd. Is there a good way to do it?
但每次,我都必须执行两个 cmd。有什么好的方法吗?
回答by AKX
The pkillutility can look at command lines when sending signals:
该pkill实用程序可以在发送信号时查看命令行:
pkill -f xxx.py

