pol*_*rto 33 bash kill process nohup
我执行了以下命令
$ nohup ./tests.run.pl 0 &
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试使用时将其杀死(以及从此脚本启动的执行)
$ kill -0 <process_id>
Run Code Online (Sandbox Code Playgroud)
这是行不通的.如何杀死nohupped进程以及通过nohupped脚本运行的进程?
谢谢
Mat*_*Mat 44
kill -0并不能杀死进程.它只是检查你是否可以向它发送信号.
简单地说kill pid,如果这不起作用,请尝试kill -9 pid.
tro*_*foe 27
简单地kill <pid>发送一个SIGTERM,nohup不会忽略.
你不应该发送SIGKILL第一个,因为这使得这个过程没有机会恢复; 你应该按顺序尝试以下方法:
SIGTERM (15)SIGINT (2)SIGKILL (9)如果您不知道进程 id,并且它可能会在 shell(或循环)中运行各种命令,您可以运行jobs -l以列出作业和 PID,然后是kill它们。
见示例:
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$
Run Code Online (Sandbox Code Playgroud)
小智 6
我会做类似的事情:
jobs
[1] + Running nohup ./tests.run.pl
kill %1
Run Code Online (Sandbox Code Playgroud)