bash 脚本无法作为后台进程正确运行

发布于 2024-08-14 11:57:10 字数 180 浏览 3 评论 0原文

我有 bash 脚本,效果很好,但是当我用 nohup script & 发回它时 并关闭我的终端会话,然后它就无法正常工作。它仅在我打开的终端会话中运行良好。

在没有终端会话的情况下,影响我的脚本运行不正确的可能原因有哪些?它可能是终端变量之一还是其​​他什么?

索拉里斯10

I have bash script which works well but when I send it back with nohup script &
and close my terminal session then it's not working correctly. It only works well within my terminal session open.

What could be possible reasons which affects my script run not correctly without my terminal session? Could it be one of the terminal variables or something?

solaris 10

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无人问我粥可暖 2024-08-21 11:57:10

call:

script &
disown $!

& 在后台启动您的脚本,并 disown $! 将最后执行的命令与当前 shell 分离。 $! 是最后一个后台执行命令的PID。

call:

script &
disown $!

& launches your script in the background and disown $! detaches last executed command from the current shell. $! is the PID of the last background executed command.

你如我软肋 2024-08-21 11:57:10

没有消息来源我们只能猜测。但是,您的用例可能非常适合使用 GNU Screen: http://www.gnu.org /software/screen/ 您可以从当前登录中分离 shell 会话,并在稍后再使用它们。

以我的拙见,这是地球上最有用的程序之一;)

Without the source we can only make guesses. However, your usecase might be a good fit for using GNU Screen: http://www.gnu.org/software/screen/ You can detach shell sessions from your current login and pick them up later on.

In my humble opinion one of the most useful programs on earth ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文