disown
Detach a background process from the shell
TLDR
Disown the current job
Disown a specific job (run jobs to find the job number)
Disown all jobs (Bash only)
Keep job (do not disown it), but mark it so that no future SIGHUP is received on shell exit (Bash only)
SYNOPSIS
disown [-ar] [-h] [jobspec ...]
disown [-h] [jobspec ...]
PARAMETERS
-a
Remove all jobs from the table (cannot combine with other options)
-r
Remove only running jobs
-h
Mark jobs to ignore SIGHUP on shell exit, without removing from table
jobspec
Job identifier (%n, %string, %+, %-, %%); defaults to current job if omitted
DESCRIPTION
The disown command is a bash builtin that removes one or more jobs from the shell's active jobs table. This prevents the shell from sending a SIGHUP (hangup) signal to those jobs upon shell exit or logout, allowing background processes to continue running independently.
Commonly used for long-running tasks like downloads, compilations, or servers started in an SSH session. For example, run command & to background it, then disown to detach. Without arguments, it targets the current job (%+). Jobs are managed via job control features, visible with jobs.
Options provide flexibility: -a removes all jobs, -r only running ones, and -h marks jobs to ignore SIGHUP without removal (useful for nohup-like behavior). Jobspecs like %1, %string, or %% specify targets.
Unlike nohup, which redirects output and ignores SIGHUP from the start, disown acts post-launch on managed jobs. It integrates with bg and fg for suspension/resumption. Requires an interactive shell with job control enabled (default in terminals).
CAVEATS
Only prevents shell-sent SIGHUP; processes remain session-attached and can be killed by logout scripts, SIGTERM, or OOM. Requires interactive shell with job control (shopt -u job_control disables). Bash-specific; not in POSIX sh.
USAGE EXAMPLE
sleep 3600 &
disown # Detach last background job
jobs # List jobs (detached ones vanish)
disown -a # Detach all jobs
WITH -H
command &
disown -h %1 # Marks job; visible in jobs but ignores SIGHUP
HISTORY
Bash builtin since version 1.14 (1994); enhanced in bash-2.0 (1996) with -h option for better job control integration.


