【发布时间】:2017-01-25 12:56:17
【问题描述】:
我如何在 bash 中运行命令来杀死除名为 test.py 的脚本和 grep 的 pid 本身之外的所有 python 脚本,以防我们使用类似 ps -ef |grep 的东西
我想我可以使用 pgrep python 之类的东西来忽略 grep 进程,但我如何也排除 test.py 脚本?我知道有一个选项可以执行 grep -v,是否有选项可以执行 pgrep -v
澄清:除了 grep 进程-意味着当我们执行例如 ps -ef |grep test1.py 时,我们还会获得用于带来此结果的 grep pid。我不想杀死它,因为在显示结果的阶段不再存在这个过程。
编辑:
我需要此命令通过 python 的 subprocess 模块有效k = subprocess.Popen('[some_bash_cmd_here]',shell=True)k.wait()
【问题讨论】:
标签: linux bash python-2.7 shell centos