我了解 nohup
和&
的区别- 和ampersand“> nohup和ampersand之间有什么
区别
当这些启动方法以完全不会发送叹气方式配置时,这些启动方法没有区别。
https://stackoverflow.com/a/58691817
如果您使用bash,则可以使用命令shopt | Grep Hupon找出您的外壳是否向其子进程叹了口气。如果关闭,过程将不会终止,
https://stackoverflow.com/a/15595391
我知道,如果 shopt | Grep Hupon
关闭,然后 nohup ./foo.sh&
and 和 ./ foo.sh&
在关闭Bash会话后仍将运行。
确实,当我通过 ps -ef |检查状态时,两者都在运行。 grep foo.sh
。
但是,当我参加TMUX会话时,行为是不同的。首先, shopt | Grep Hupon
在TMUX会话中也关闭。但是结果是只有 nohup ./foo.sh&
在杀死TMUX会话后可以继续运行。
TMUX会话和BASH会话之间应该有一些不同的事物,这会导致上述不同的行为。谁能解释或给出一些提示?
I learn the difference between nohup
and &
from What's the difference between nohup and ampersand
Based on the following answers,
There is no difference between these launching methods when the shell is configured in a way where it does not send SIGHUP at all.
https://stackoverflow.com/a/58691817
In case you're using bash, you can use the command shopt | grep hupon to find out whether your shell sends SIGHUP to its child processes or not. If it is off, processes won't be terminated,
https://stackoverflow.com/a/15595391
I learn that if shopt | grep hupon
is off, then nohup ./foo.sh &
and ./foo.sh &
would be still running after closing the bash sessions.
Indeed, both are running when I check the status via ps -ef | grep foo.sh
.
However, the behaviors are different when I move to tmux sessions. Firstly, shopt | grep hupon
is also off in tmux sessions. But the result is that only nohup ./foo.sh &
can keep running after killing the tmux session.
There should be something different between the tmux session and the bash session, which causes the above different behaviors. Could anyone explain it or give some hints?
发布评论