Korean

nohup — Keep a command running after logout

Linux / Service and process management / nohup.html

Service and process managementOriginalRegistered 2026-10-20T09:00:00+09:00

Makes a command ignore hangup signals and redirects output so it survives logout.

Basic Information

Command Namenohup
One-line IntroductionMakes a command ignore hangup signals and redirects output so it survives logout.
Provided byGNU coreutils (installed by default)
Official Documentationhttps://man7.org/linux/man-pages/man1/nohup.1.html
Supported Operating SystemsLinux, macOS, BSD
Installation StatusInstalled by default (no separate installation needed)
CategoryLinux service and process management (tags: Process and resource management (tags: background, session, logout))

What is this command?

nohup ignores SIGHUP and redirects standard output and error to nohup.out by default.

It is the simplest way to keep a long job alive when an SSH session may drop.

What problems does it solve?

  • Keep a long backup running after SSH exits.
  • Prevent a dropped session from killing a build.
  • Capture output in a file for later review.
  • Run an ad-hoc batch job in the background.

Key features

Signal handling

Runs the child with SIGHUP ignored.

  • When to use: Environments where sessions drop
  • What you get: Still running after logout
  • Limitations: A KILL signal still ends it

Output redirection

When output is not a terminal it appends to nohup.out.

  • When to use: When keeping a run log
  • What you get: Records into nohup.out
  • Limitations: The file keeps growing

Combining with background

A trailing & returns the shell immediately.

  • When to use: When the shell is still needed
  • What you get: A job running in the background
  • Limitations: Completion must be checked separately

Installation and usage

Check whether it is installed

nohup --version

apt install coreutils # usually already present

Real-world examples

Background run

Start a job that survives logout.

# Keep running after logout, in the background
nohup ./long-task.sh &

Custom log file

Write to a chosen path instead of nohup.out.

# Write output to a specific file
nohup ./backup.sh > /var/log/backup.log 2>&1 &

Check the job

Check state with jobs and ps.

# Confirm the job is still alive
ps -ef | grep long-task