Linux / Unix: disown Command Examples

Linux / Unix: disown Command Examples

The disown command is used to remove a job from the job control of the current shell in Unix and Linux systems. When you run a command in the background using the & operator, it becomes a job that is controlled by the shell. You can use the disown command to remove a job from the job control of the shell, so that it continues running even after the shell exits.

Here is the basic syntax for using the disown command:

re‮ref‬ to:lautturi.com
disown [-h] [-ar] [jobspec ...]

The -h option tells the shell to mark the job as "no hangup", which means that the job will not receive a SIGHUP signal when the terminal disconnects. The -a option tells the shell to operate on all jobs, and the -r option tells the shell to operate only on running jobs. The jobspec argument specifies the job or jobs that you want to disown.

Here are some examples of using the disown command:

  1. Disown a specific job: To disown a specific job, you can use the job number or the job name preceded by a percent sign (%).

For example, to disown the job with job number 1, you can use the following command:

disown %1

To disown the job with the name myjob, you can use the following command:

disown %myjob
  1. Disown all jobs: To disown all jobs, you can use the -a option.

For example:

disown -a

This will disown all jobs in the current shell.

  1. Disown running jobs: To disown only running jobs, you can use the -r option.

For example:

disown -r

This will disown all running jobs in the current shell.

Created Time:2017-10-29 22:09:00  Author:lautturi