nohup flags & options

Basic usage

Run a command that continues after you log out. Output goes to nohup.out.

nohup ./long_running_script.sh &

Redirect output

Send output to a specific file instead of nohup.out.

nohup ./process.sh > output.log 2>&1 &

Suppress output

Discard all output.

nohup ./process.sh > /dev/null 2>&1 &

With specific log files

Separate stdout and stderr.

nohup ./server.sh > stdout.log 2> stderr.log &

Check the background process

jobs -l
ps aux | grep process.sh

Common patterns

Start a server that survives logout.

nohup python3 server.py &

Run a long download.

nohup wget https://example.com/large-file.iso &

Difference from disown

nohup prevents SIGHUP from the start. disown removes an already-running job from the shell's job table.

./process.sh &
disown