I have a process that is already running for a long time and don't want to end it.
How do I put it under nohup (that is, how do I cause it to continue running even if I close the terminal?)
Run our command in the first tab of our terminal. While running, we open another tab of our terminal and run the command disown -a . Then, we close the first terminal. Then our process will still run in the background even after closing the terminal.
Use bg to Send Running Commands to the Background You can easily send these commands to the background by hitting the Ctrl + Z keys and then using the bg command. Ctrl + Z stops the running process, and bg takes it to the background.
In order to place a foreground proces into the background, we must first put the process to sleep, and then place it in the background. Execute the command to run your process. Press CTRL+Z to put the process into sleep. Run the bg command to wake the process and run it in the backround.
You could move the running process into a background and then run other commands. To do this, you would first type ^z (hold control key and press z). That suspends the process. Then type bg to put the process in the background.
Using the Job Control of bash to send the process into the background:
bg
to run it in the background.disown -h [job-spec]
where [job-spec] is the job number (like %1
for the first running job; find about your number with the jobs
command) so that the job isn't killed when the terminal closes.Suppose for some reason Ctrl+Z is also not working, go to another terminal, find the process id (using ps
) and run:
kill -SIGSTOP PID kill -SIGCONT PID
SIGSTOP
will suspend the process and SIGCONT
will resume the process, in background. So now, closing both your terminals won't stop your process.
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