如何杀死 nohup 进程?
我现在执行了以下命令,
$ nohup ./tests.run.pl 0 &
当我尝试杀死它(以及从该脚本启动的执行)时,
$ kill -0 <process_id>
但使用它不起作用。如何终止 nohupped 进程以及通过 nohupped 脚本运行的进程?
谢谢
I executed the following command
$ nohup ./tests.run.pl 0 &
now when I try to kill it (and the executions that are started from this script) using
$ kill -0 <process_id>
it does not work. How can I kill a nohupped process and the processes that runs via the nohupped script?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
kill -0
确实不会终止进程。它只是检查您是否可以向它发送信号。只需
kill pid
,如果这不起作用,请尝试kill -9 pid
。kill -0
does not kill the process. It just checks if you could send a signal to it.Simply
kill pid
, and if that doesn't work, trykill -9 pid
.只需
kill
即可发送SIGTERM
,而nohup
不会忽略该信号。您不应该首先发送
SIGKILL
,因为这会让进程没有机会恢复;您应该按顺序尝试以下操作:SIGTERM
(15)SIGINT
(2)SIGKILL
(9)Simply
kill <pid>
which will send aSIGTERM
, whichnohup
won't ignore.You should not send a
SIGKILL
first as that gives the process no chance to recover; you should try the following, in order:SIGTERM
(15)SIGINT
(2)SIGKILL
(9)我会做类似的事情:
I would do something like:
如果您不知道进程 ID 并且它可能在 shell(或循环)内运行各种命令,您可以运行
jobs -l
来列出作业和 PID,然后kill他们。
参见示例:
If you don't know the process ids and it might run various commands within a shell (or a loop), you can run
jobs -l
to list jobs and PIDs, thenkill
them.See example:
杀死
nohup
进程grep
PID
kill -15 -1 16000
(将注销您)并在下次登录 root 时清除kill
nohup
processgrep that
PID
kill -15 -1 16000
(will logout you) and clean on next login root