nohup ("no hangup") runs a command so that it ignores the SIGHUP signal, letting it survive the closing of its controlling terminal. Output is redirected to nohup.out in the current directory unless explicitly redirected.
nohup ./long-job.sh & # run in background, survives logout
nohup ./job.sh > job.log 2>&1 & # redirect output explicitly
nohup ./job.sh < /dev/null > log 2>&1 & # fully detach
On a modern system with tmux or screen, those are usually a better tool for long-running interactive work. nohup is still the right choice for one-shot, fire-and-forget scripts, and it requires nothing beyond coreutils.
Discussed in:
- Chapter 10: Processes and Job Control — Backgrounding and Detaching