Differences between “ & disown” and “nohup & disown”
up vote
30
down vote
favorite
This is my understanding about the usage of &
, disown
and nohup
:
<command>
: runs the process within the Terminal's currentbash
instance, in the foreground (i.e. the process is listed as abash
foreground job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> &
: runs the process within the Terminal's currentbash
instance, in the background (i.e. the process is listed as abash
background job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are still bound to the terminal); immune to hangups;
nohup <command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are not still bound to the terminal);immune to hangups;
So, aside from nohup <command> & disown
blocking stdin
and redirecting stdout
and stderr
to nohup.out
by default, it seems to me like it can be considered totally equivalent to <command> & disown
.
Is the above all correct? Any misconception?
command-line bash nohup background-process
add a comment |
up vote
30
down vote
favorite
This is my understanding about the usage of &
, disown
and nohup
:
<command>
: runs the process within the Terminal's currentbash
instance, in the foreground (i.e. the process is listed as abash
foreground job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> &
: runs the process within the Terminal's currentbash
instance, in the background (i.e. the process is listed as abash
background job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are still bound to the terminal); immune to hangups;
nohup <command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are not still bound to the terminal);immune to hangups;
So, aside from nohup <command> & disown
blocking stdin
and redirecting stdout
and stderr
to nohup.out
by default, it seems to me like it can be considered totally equivalent to <command> & disown
.
Is the above all correct? Any misconception?
command-line bash nohup background-process
1
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
2
@chaos I mean that terminating / killing the parentbash
instance won't kill the process
– kos
Apr 21 '15 at 9:42
add a comment |
up vote
30
down vote
favorite
up vote
30
down vote
favorite
This is my understanding about the usage of &
, disown
and nohup
:
<command>
: runs the process within the Terminal's currentbash
instance, in the foreground (i.e. the process is listed as abash
foreground job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> &
: runs the process within the Terminal's currentbash
instance, in the background (i.e. the process is listed as abash
background job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are still bound to the terminal); immune to hangups;
nohup <command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are not still bound to the terminal);immune to hangups;
So, aside from nohup <command> & disown
blocking stdin
and redirecting stdout
and stderr
to nohup.out
by default, it seems to me like it can be considered totally equivalent to <command> & disown
.
Is the above all correct? Any misconception?
command-line bash nohup background-process
This is my understanding about the usage of &
, disown
and nohup
:
<command>
: runs the process within the Terminal's currentbash
instance, in the foreground (i.e. the process is listed as abash
foreground job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> &
: runs the process within the Terminal's currentbash
instance, in the background (i.e. the process is listed as abash
background job andstdin
,stdout
andstderr
are still bound to the terminal); not immune to hangups;
<command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are still bound to the terminal); immune to hangups;
nohup <command> & disown
: runs the process within the Terminal's currentbash
instance, in the background, but the process is detached from thebash
's jobs' list (i.e. the process is not listed as abash
foreground / background job andstdin
,stdout
andstderr
are not still bound to the terminal);immune to hangups;
So, aside from nohup <command> & disown
blocking stdin
and redirecting stdout
and stderr
to nohup.out
by default, it seems to me like it can be considered totally equivalent to <command> & disown
.
Is the above all correct? Any misconception?
command-line bash nohup background-process
command-line bash nohup background-process
edited Apr 21 '15 at 15:30
asked Apr 21 '15 at 9:22
kos
25.2k869119
25.2k869119
1
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
2
@chaos I mean that terminating / killing the parentbash
instance won't kill the process
– kos
Apr 21 '15 at 9:42
add a comment |
1
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
2
@chaos I mean that terminating / killing the parentbash
instance won't kill the process
– kos
Apr 21 '15 at 9:42
1
1
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
2
2
@chaos I mean that terminating / killing the parent
bash
instance won't kill the process– kos
Apr 21 '15 at 9:42
@chaos I mean that terminating / killing the parent
bash
instance won't kill the process– kos
Apr 21 '15 at 9:42
add a comment |
2 Answers
2
active
oldest
votes
up vote
22
down vote
accepted
Your understanding is basically correct. Both disown
and nohup
are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:
There's no reason to run
nohup command & disown
,nohup
will already disown it for you.nohup
is defined by POSIX whiledisown
is not. This means that while many shells (e.g.bash
,zsh
,ksh
) have it, others (for exampletcsh
,csh
,dash
andsh
) won't have it.disown
can be used after a command has been launched whilenohup
must be used before.
As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown
and man nohup
) but their basic function is the same, yes.
For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:
- Do
disown -h
andnohup
work effectively the same? - Difference between nohup, disown and &
11
Nohup
anddisown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
– memo
Feb 10 '16 at 21:53
add a comment |
up vote
7
down vote
Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal
is not a right notion. stdin
is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal
is alright.
Your have stdin, stdout and stderr are not still bound to the terminal
in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null
as the input file to the command
, for example if the command is cat
, you are using it as cat /dev/null
.
The command on your 5th point is not correctly put, you used nohup <command> & disown
, while using any one of nohup
or disown
the other one is not needed. Their purposes are the same (to ignore the SIGHUP
) but they function in a bit different way. So the command can be simplified as nohup <command> &
.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
22
down vote
accepted
Your understanding is basically correct. Both disown
and nohup
are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:
There's no reason to run
nohup command & disown
,nohup
will already disown it for you.nohup
is defined by POSIX whiledisown
is not. This means that while many shells (e.g.bash
,zsh
,ksh
) have it, others (for exampletcsh
,csh
,dash
andsh
) won't have it.disown
can be used after a command has been launched whilenohup
must be used before.
As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown
and man nohup
) but their basic function is the same, yes.
For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:
- Do
disown -h
andnohup
work effectively the same? - Difference between nohup, disown and &
11
Nohup
anddisown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
– memo
Feb 10 '16 at 21:53
add a comment |
up vote
22
down vote
accepted
Your understanding is basically correct. Both disown
and nohup
are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:
There's no reason to run
nohup command & disown
,nohup
will already disown it for you.nohup
is defined by POSIX whiledisown
is not. This means that while many shells (e.g.bash
,zsh
,ksh
) have it, others (for exampletcsh
,csh
,dash
andsh
) won't have it.disown
can be used after a command has been launched whilenohup
must be used before.
As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown
and man nohup
) but their basic function is the same, yes.
For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:
- Do
disown -h
andnohup
work effectively the same? - Difference between nohup, disown and &
11
Nohup
anddisown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
– memo
Feb 10 '16 at 21:53
add a comment |
up vote
22
down vote
accepted
up vote
22
down vote
accepted
Your understanding is basically correct. Both disown
and nohup
are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:
There's no reason to run
nohup command & disown
,nohup
will already disown it for you.nohup
is defined by POSIX whiledisown
is not. This means that while many shells (e.g.bash
,zsh
,ksh
) have it, others (for exampletcsh
,csh
,dash
andsh
) won't have it.disown
can be used after a command has been launched whilenohup
must be used before.
As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown
and man nohup
) but their basic function is the same, yes.
For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:
- Do
disown -h
andnohup
work effectively the same? - Difference between nohup, disown and &
Your understanding is basically correct. Both disown
and nohup
are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:
There's no reason to run
nohup command & disown
,nohup
will already disown it for you.nohup
is defined by POSIX whiledisown
is not. This means that while many shells (e.g.bash
,zsh
,ksh
) have it, others (for exampletcsh
,csh
,dash
andsh
) won't have it.disown
can be used after a command has been launched whilenohup
must be used before.
As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown
and man nohup
) but their basic function is the same, yes.
For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:
- Do
disown -h
andnohup
work effectively the same? - Difference between nohup, disown and &
edited Nov 27 at 1:42
answered Apr 21 '15 at 15:51
terdon♦
63.8k12135212
63.8k12135212
11
Nohup
anddisown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
– memo
Feb 10 '16 at 21:53
add a comment |
11
Nohup
anddisown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
– memo
Feb 10 '16 at 21:53
11
11
Nohup
and disown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description– memo
Feb 10 '16 at 21:53
Nohup
and disown
are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description– memo
Feb 10 '16 at 21:53
add a comment |
up vote
7
down vote
Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal
is not a right notion. stdin
is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal
is alright.
Your have stdin, stdout and stderr are not still bound to the terminal
in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null
as the input file to the command
, for example if the command is cat
, you are using it as cat /dev/null
.
The command on your 5th point is not correctly put, you used nohup <command> & disown
, while using any one of nohup
or disown
the other one is not needed. Their purposes are the same (to ignore the SIGHUP
) but they function in a bit different way. So the command can be simplified as nohup <command> &
.
add a comment |
up vote
7
down vote
Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal
is not a right notion. stdin
is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal
is alright.
Your have stdin, stdout and stderr are not still bound to the terminal
in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null
as the input file to the command
, for example if the command is cat
, you are using it as cat /dev/null
.
The command on your 5th point is not correctly put, you used nohup <command> & disown
, while using any one of nohup
or disown
the other one is not needed. Their purposes are the same (to ignore the SIGHUP
) but they function in a bit different way. So the command can be simplified as nohup <command> &
.
add a comment |
up vote
7
down vote
up vote
7
down vote
Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal
is not a right notion. stdin
is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal
is alright.
Your have stdin, stdout and stderr are not still bound to the terminal
in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null
as the input file to the command
, for example if the command is cat
, you are using it as cat /dev/null
.
The command on your 5th point is not correctly put, you used nohup <command> & disown
, while using any one of nohup
or disown
the other one is not needed. Their purposes are the same (to ignore the SIGHUP
) but they function in a bit different way. So the command can be simplified as nohup <command> &
.
Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal
is not a right notion. stdin
is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal
is alright.
Your have stdin, stdout and stderr are not still bound to the terminal
in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null
as the input file to the command
, for example if the command is cat
, you are using it as cat /dev/null
.
The command on your 5th point is not correctly put, you used nohup <command> & disown
, while using any one of nohup
or disown
the other one is not needed. Their purposes are the same (to ignore the SIGHUP
) but they function in a bit different way. So the command can be simplified as nohup <command> &
.
answered Apr 21 '15 at 9:51
heemayl
65.6k8136210
65.6k8136210
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f611968%2fdifferences-between-command-disown-and-nohup-command-disown%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36
2
@chaos I mean that terminating / killing the parent
bash
instance won't kill the process– kos
Apr 21 '15 at 9:42