nohup 和 bg 有什么区别?

What are the differences between nohup and bg?

直到今天我才使用nohup命令,但现在我需要使用它来运行后台命令。

据我所知,我还可以使用 bg 命令在后台 运行 进程。所以我的问题是,nohupbg 命令有什么区别?

以 'bg' 为背景的进程仍然与启动它们的 shell 相关联,并会在 shell 关闭时关闭。使用 'nohup' 分离的进程将 运行 即使在您注销后也是如此。