How to kill a nohup process?

孤街醉人 提交于 2019-11-29 19:52:44

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, try kill -9 pid.

Simply kill <pid> which will send a SIGTERM, which nohup 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)
user7321649

I would do something like:

jobs

[1] + Running nohup ./tests.run.pl

kill %1

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.

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$
san shrestha

kill nohup process

ps aux |grep nohup

grep that PID kill -15 -1 16000 (will logout you) and clean on next login root

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!