Quote:
Originally Posted by
JackK
I forgot to tell that "nohup my_script.sh..." is executed inside parent shell script, which was used to prepare my_script.sh
Does this change anything?
As it is i already suspected that, so: no, that doesn't change anything.
It is like this: when you start a login shell a "terminal" is created (by a process called
getty or something analogous). This terminal is part of the process environment of your login session and is then "inherited" thoughout the process tree originating in your login session. That is, whatever you start from there - foreground processes, background processes, ... - will always use this terminal for any (not-redirected) output. As soon as this terminal ceases to exist (i.e. you log off) all the other processes using this terminal too will also be terminated, because they too lose their terminal.
Now, you might want to have processes continue to run without your session remaining - in fact, this is what most applications are supposed to do: they should continue to run even if the session where they are started ends. One needs a way of telling a process that "yes, there is a terminal, but don't care if it goes away".
For exactly this purpose there is nohup ("no termination on hangup") and this is what it does. Still: this only works if the program honours it (that is: there needs to be some part in the code dealing with it) and second: it doesn't matter if the process is started froma script or by hand: this influences only where in the process tree it is located. Since the purpose of
nohup is solely to "disown" the process it doesn't matter how it would otherwise inherit something (the terminal) it now won't.
I hope this explains it.
bakunin