How to use nohup and disown for background jobs

· Category: Linux

Short answer

nohup and disown allow processes to continue running after the terminal session ends.

Steps

  1. Run with nohup:
nohup ./long-running-script.sh > output.log 2>&1 &
  1. Disown an already running job:
./script.sh &
disown
  1. Background a job:
Ctrl+Z
bg

Tips

  • nohup redirects output to nohup.out by default.
  • disown -h prevents SIGHUP without removing the job from the shell.
  • Use screen or tmux for interactive long-running sessions.

Common issues

  • Forgetting to redirect output can fill the terminal buffer.
  • Jobs started without nohup may still receive signals after disown.