disown:tldr:bb417
The disown
command is used in Unix-like operating systems to detach a currently running job from the shell. When a process is associated with a shell, it by default receives signals from the shell and is terminated when the shell is terminated. However, using the disown
command allows a process to continue running even after the shell has been terminated.
The syntax of the disown
command is:
disown [options] [job-spec]
Here, the job-spec
refers to the job ID or process ID of the running job that you want to disown. If no job-spec
is provided, the most recent background process started by the shell is disowned.
The disown
command takes the following options:
-h
or--help
: displays a help message explaining the usage of the command.-a
or--all
: disowns all running jobs.-r
or--remove
: removes the specified jobs from the job table, effectively disowning them.
Once a job is disowned, it no longer belongs to the shell's job table and is not associated with it. This means that it won't receive any signals from the shell, including the SIGHUP
signal sent when the shell terminates. The job can still continue running in the background, interacting with the system independently.
Note that disowning a job does not change its process group ID, so it may still be affected by signals sent to its process group. However, it won't be affected by signals specifically directed at the shell process group.
The disown
command is useful when you want to detach a running process from the shell, allowing it to run independently even after you logout or close your terminal session.