使用 Screen 保持进程运行
所以我有一个域,我需要在退出 ssh 会话后保持 python 进程运行。现在,当我退出时,它就噗通了。
我被告知要使用 Screen,但我正在与这个 gnu 文档作斗争。如何使用 Screen 运行 python 进程,并在退出 ssh 会话后保持其运行?
So I have a domain and I need to keep a python process running after I exit my ssh session. Right now, when I exit, it goes poof.
I was told to use Screen, but am fighting with this gnu doc. How would I use Screen to run a python process, and keep it running after I exit my ssh session?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
登录。运行画面。启动你的 python 程序。按 crtl-a crtl-d 与屏幕分离。退出。
再次登录。 screen -r 重新连接到您的进程。
Log on. Run screen. Launch your python program. Press crtl-a crtl-d to detach from your screen. Log out.
Log in again. screen -r to reattach to your process.
尽管我喜欢 GNU Screen,但经典的解决方案是
nohup
,如果您不需要重新附加到该进程,它会更加直接且同样有用。nohup script.py
应该足够了。进程输出将保存到当前目录中的文件中。Although I love GNU Screen the classical solution for this is
nohup
, which is much more straightforward and equally useful if you don't ever need to reattach to the process.nohup script.py
should be enough. The process output gets saved to a file in the current directory.