`nohup` runs processes immune to hangup signals, allowing them to survive terminal closure

When you close your terminal or log out, the shell normally sends a SIGHUP signal to all running processes, terminating them. The nohup command (no hang up) makes processes immune to these signals, allowing them to continue running.

Basic usage:

nohup command [arguments] > /dev/null 2>&1 &

What each part does:

Example:

# Run a long-running script that survives terminal closure
nohup python training_script.py > /dev/null 2>&1 &

# Run a server process without Docker
nohup n8n start > /dev/null 2>&1 &

Why use it:

Find running nohup processes:

ps aux | grep command_name

Keep output instead:

# Save output to nohup.out (default)
nohup python script.py &

# Save to custom file
nohup python script.py > output.log 2>&1 &

This provides a lightweight alternative to systemd services, Docker containers, or tmux for simple persistent processes, especially useful on systems where you want background tasks without additional infrastructure.

Original source