difference disown nohup and &
disown -r
--------------
--------------
- 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.
-------------
154
|
Let's first look at what happens if a program is started from an interactive shell (connected to a terminal) without
& (and without any redirection). So let's assume you've just typed foo :
Now, let's look what happens if you put the process in the background, that is, type
foo & :
Now
disown removes the job from the shell's job list, so all the subpoints above don't apply any more (including the process being sent a SIGHUP by the shell). However note that it still is connected to the terminal, so if the terminal is destroyed (which can happen if it was a pty, like those created by xterm or ssh , and the controlling program is terminated, by closing the xterm or terminating the SSHconnection), the program will fail as soon as it tries to read from standard input or write to standard output.
What
nohup does, on the other hand, is to effectively separate the process from the terminal:
Note that
nohup does not remove the process from the shell's job control and also doesn't put it in the background (but since a foreground nohup job is more or less useless, you'd generally put it into the background using & ). For example, unlike with disown , the shell will still tell you when the nohup job has completed (unless the shell is terminated before, of course).
So to summarize:
|
Comments
Post a Comment