nohup

Linux · Processes · reference only

What it does

Runs a command that ignores the hangup signal, so it keeps running after you leave the terminal.

Syntax

nohup comando [argumentos...]

Options and parameters

  • comando

    Program that runs immune to session closing.

  • &

    Written at the end to leave the command in the background.

  • > fichero 2>&1

    Redirects output and errors to a file instead of nohup.out.

  • --help

    Shows help and exits.

  • --version

    Shows the version and exits.

Usage examples

  • nohup sleep 100 &

    Starts a 100-second wait in the background that survives closing the terminal.

  • nohup ./copia.sh > copia.log 2>&1 &

    Runs a long script and saves its output to copia.log.

  • tail -f nohup.out

    Follows live the output that nohup saves by default.

  • nohup python3 servidor.py &

    Keeps a simple server running even if you close the SSH session.

Notes and common mistakes

  • If standard output is a terminal and you did not redirect it, nohup saves it to nohup.out.
  • For long-running processes a systemd service, tmux or screen is usually better.

Related commands