Frequently Asked Question
How can I keep a process running after I log out, nohup vs disown vs &?
A plain command & runs the program in the background but does not detach it from
the shell: when you exit, bash sends SIGHUP to all its jobs and they die. The three
idiomatic ways to survive that hangup are nohup, disown, and a terminal
multiplexer. nohup command & arranges before launch that the process ignores
SIGHUP and redirects its standard output and error to nohup.out so they have
somewhere to go after the terminal is gone.
disown is the same idea applied after the fact: start the job normally, then run
disown %1 (or disown -h %1 to leave it in the jobs table but mark it
hangup-immune). For anything non-trivial, especially over SSH, the right answer is
tmux or screen, which run the process inside a persistent virtual terminal you
can detach from and reconnect to from any machine. Picking nohup or disown is fine
for fire-and-forget batch jobs; pick tmux for anything you want to come back and
interact with.