bash 如何杀死 nohup 进程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8007380/
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 nohup process?
提问by polerto
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?
这是行不通的。如何杀死 nohupped 进程以及通过 nohupped 脚本运行的进程?
Thanks
谢谢
回答by Mat
kill -0
does notkill the process. It just checks if you could send a signal to it.
kill -0
并不能杀死进程。它只是检查您是否可以向它发送信号。
Simply kill pid
, and if that doesn't work, try kill -9 pid
.
很简单kill pid
,如果这不起作用,请尝试kill -9 pid
。
回答by trojanfoe
Simply kill <pid>
which will send a SIGTERM
, which nohup
won't ignore.
简单地说kill <pid>
,它会发送一个SIGTERM
,它nohup
不会忽略。
You should not send a SIGKILL
first as that gives the process no chance to recover; you should try the following, in order:
您不应该发送SIGKILL
第一个,因为这使该过程没有机会恢复;您应该按顺序尝试以下操作:
SIGTERM
(15)SIGINT
(2)SIGKILL
(9)
SIGTERM
(15)SIGINT
(2)SIGKILL
(9)
回答by user7321649
I would do something like:
我会做这样的事情:
jobs
[1] + Running nohup ./tests.run.pl
kill %1
回答by Mike S.
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, then kill
them.
如果您不知道进程 id,并且它可能会在 shell(或循环)中运行各种命令,您可以运行jobs -l
以列出作业和 PID,然后是kill
它们。
See example:
见示例:
ubuntu@app2:/usr/share/etlservice/bin$ jobs -l
[1] 27398 Running nohup ./extract_assessor_01.sh > job1.log &
[2] 27474 Running nohup ./extract_assessor_02.sh > job2.log &
[3] 27478 Running nohup ./extract_assessor_03.sh > job3.log &
[4]- 27481 Running nohup ./extract_assessor_04.sh > job4.log &
[5]+ 28664 Running nohup ./extract_assessor_01.sh > job1.log &
ubuntu@app2:/usr/share/etlservice/bin$ sudo kill 27398
sudo kill 27474[1] Terminated nohup ./extract_assessor_01.sh > job1.log
ubuntu@app2:/usr/share/etlservice/bin$ sudo kill 27474
[2] Terminated nohup ./extract_assessor_02.sh > job2.log
ubuntu@app2:/usr/share/etlservice/bin$ sudo kill 27478
[3] Terminated nohup ./extract_assessor_03.sh > job3.log
ubuntu@app2:/usr/share/etlservice/bin$ sudo kill 27481
[4]- Terminated nohup ./extract_assessor_04.sh > job4.log
ubuntu@app2:/usr/share/etlservice/bin$ sudo kill 28664
[5]+ Terminated nohup ./extract_assessor_01.sh > job1.log
ubuntu@app2:/usr/share/etlservice/bin$
回答by san shrestha
kill nohup
process
杀死nohup
进程
ps aux |grep nohup
grep that PID
kill -15 -1 16000
(will logout you) and clean on next login root
grep 那个PID
kill -15 -1 16000
(将注销你)并在下次登录 root 时清理