$linuxjunkies
>

nohup(1)

Run a command immune to hangups, with output redirected to a file.

UbuntuDebianFedoraArch

Synopsis

nohup COMMAND [ARG]...

Description

nohup runs a command with hangup signals ignored, allowing it to continue running even after the terminal closes or the user logs out. By default, standard output is redirected to nohup.out in the current directory, and standard error is redirected to the same file.

This is essential for long-running tasks, batch jobs, and server processes that should persist beyond the login session. The command creates nohup.out (or appends to it if it exists) unless output redirection is explicitly specified on the command line.

Common options

FlagWhat it does
(no flags)nohup has no option flags; use shell redirection to control output

Examples

Run long_script.sh in the background, immune to hangups; output goes to nohup.out

nohup ./long_script.sh &

Run a Python training script and redirect both stdout and stderr to training.log

nohup python train_model.py > training.log 2>&1 &

Run a long rsync backup that survives logout; capture output in rsync.log

nohup rsync -av /source /dest > rsync.log &

Send a long-running HTTP request in the background

nohup curl -X POST https://api.example.com/job -d @payload.json &

Monitor a log file and filter errors, persisting across disconnection

nohup tail -f /var/log/app.log | grep ERROR > errors.txt &

Run a build script and disown it to fully detach from the shell

nohup ./build.sh &disown

Related commands