Differences between "<command> & disown" and "nohup <command> & disown"
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 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> &
.