Back to the command reference

nohup

ProcessesFundamentals In real Linux

Keep a command running after you log out

Name: nohup = no hang up

This command needs a real Linux system; you can practise it in real Linux mode.

Description

nohup runs a command immune to SIGHUP. Closing a terminal or SSH session sends SIGHUP to its processes, which usually ends them; commands started with nohup keep going, with output in nohup.out by default.

For long sessions you can reattach to, tmux or screen are better.

Syntax

nohup COMMAND [ARG]... &

Common options

&Run in the background
nohup.outDefault output file

Examples

  • $ nohup python train.py > train.log 2>&1 &

    Training keeps going after you close the terminal

    Explain
  • $ tail -f nohup.out

    Follow the output

    Explain

Related