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
When using nohup and you put the task in the background, the background operator ( & ) will give you the PID at the command prompt. If your plan is to manually manage the process, you can save that PID and use it later to kill the process if needed, via kill PID or kill -9 PID (if you need to force kill).
nohup prevents the process from receiving SIGHUP signal whereas CTRL+C sends SIGINT signal. That's why nohup doesn't have the effect you expected.
Use CTRL + Z Another method to put a process in the background is to use the CTRL + Z shortcut. Suppose we forgot to add the ampersand when running a program. To put the said process in the background, we can press the CTRL + Z key and suspend the job.
To check the results or status of the programs, log back in to the same server. Once the job has finished its output will be contained in a file located within your home space. The filename will be "nohup. out" (no quotes).
When using nohup and you put the task in the background, the background operator (&) will give you the PID at the command prompt. If your plan is to manually manage the process, you can save that PID and use it later to kill the process if needed, via kill PID or kill -9 PID (if you need to force kill).
When using nohup and you put the task in the background, the background operator ( &) will give you the PID at the command prompt. If your plan is to manually manage the process, you can save that PID and use it later to kill the process if needed, via kill PID or kill -9 PID (if you need to force kill).
Your process 14224 is the grep nohup, as ps told you. So, when you get your prompt back, the grep ended and therefore, it is logical that kill reports that there is no such process. You will not see s process called nohup in your ps output. So, how to find the process to kill? As I don't have your beast-2, I will demonstrate with nohup sleep 99 &.
You could also use the screen command to initialize a session, run your command and detach from the session. That way you can reconnect and see what's up. To stop the nohup, do a pgrep for the command you launched and kill it either by PID or name (using pkill).
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)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With