24

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?

Amelio Vazquez-Reina
  • 40,169
  • 77
  • 197
  • 294
  • 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 08:26

1 Answers1

31

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 &!
alienth
  • 2,187
  • 12
  • 20