2017-07-31 110 views
0

我想上一个数字海洋(DO)滴(的Ubuntu 16)运行此Python的脚本远程服务器上运行的Python脚本: https://github.com/instabot-py/instabot.py通过SSH

虽然我可以运行python3 example.py进程停止,如果我杀了终端windown我用SSH进入DO滴。

有没有办法运行这个Python脚本,并断开与仍然运行的Python脚本的DO Droplet?

+0

https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session –

+1

[断开后保持SSH会话运行 - 过夜](https: //stackoverflow.com/questions/33205456/keep-ssh-sessions-running-after-disconnection-for-overnight) –

回答

1

您可以在Linux中使用screen,即使在与服务器断开连接后,仍可继续在后台执行此过程。 同样可以使用tmux

this问题的答案很可能是你在找什么。

0

我们用下面的格式来执行远程脚本 ssh -t -t [email protected] 'nohup /path/to/scrip.py'

1

使用nohup在后台

nohup python3 example.py > /dev/null 2>&1 & 

运行程序或者您可以使用screen做到这一点:

$ screen 
$ python3 example.py 
To detach the current session, you can press Ctrl+A and then press D. 
To re-attach previous session, use command `screen -r` 

screen命令比更强大210。