Say I run the following on a remote box with the idea of preventing killing the job when I disconnect the terminal.

nohup ./my_script.sh &

When I try to exit my terminal, I got the following warning:

zsh: you have running jobs

I presume that's ok. It's just telling me that I have a job / process running in the background. If I disconnect the terminal, the job/process will continue to run, correct?

  • I found that zsh's nohup is broken and doesn't do what you want. Disown works most of the time. Though once I had an issue trying to use disown with ffmpeg in zsh, so started a bash shell and ran nohup inside that. – Sridhar Sarnobat Nov 27 '16 at 8:26

Yeah, that's fine. The child process will receive a HUP signal, but the process won't die thanks to your nohup.

If you want to not see that message, simply pass the job id to disown, like so:

disown %1

Or, start the job with &! (zsh-specific trick):

nohup ./my_script.sh &!
  • Can the &! trick work on the bash as well? – alper Dec 25 '20 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.