【发布时间】:2014-05-11 23:30:44
【问题描述】:
我在运行 python 程序的 Ubuntu 中使用 cron 命令:
05 23 * * * python /home/ahmed/Desktop/hello.py
如何停止程序运行?
【问题讨论】:
-
使用 ps 获取 PID(使用 grep 选择名称)然后发出 kill 有什么问题?
我在运行 python 程序的 Ubuntu 中使用 cron 命令:
05 23 * * * python /home/ahmed/Desktop/hello.py
如何停止程序运行?
【问题讨论】:
打开终端,运行
$ ps aux | grep hello.py
它会显示这样的输出 -
username NNNN 0.0 0.0 13648 940 pts/7 S+ 01:04 0:00 /usr/bin/python /home/ahmed/Desktop/hello.py
NNNN 是进程 ID。然后执行 -
$ sudo kill -9 NNNN
这应该会终止进程。如果您不想再次执行此操作,请将其从 cron 中删除。
【讨论】:
ps aux | grep hello.py 本身就是您在那里看到的过程。