我想上一个数字海洋(DO)滴(的Ubuntu 16)运行此Python的脚本远程服务器上运行的Python脚本: https://github.com/instabot-py/instabot.py通过SSH
虽然我可以运行python3 example.py
进程停止,如果我杀了终端windown我用SSH进入DO滴。
有没有办法运行这个Python脚本,并断开与仍然运行的Python脚本的DO Droplet?
我想上一个数字海洋(DO)滴(的Ubuntu 16)运行此Python的脚本远程服务器上运行的Python脚本: https://github.com/instabot-py/instabot.py通过SSH
虽然我可以运行python3 example.py
进程停止,如果我杀了终端windown我用SSH进入DO滴。
有没有办法运行这个Python脚本,并断开与仍然运行的Python脚本的DO Droplet?
您可以尝试以下Python库来实现这一
https://pypi.python.org/pypi/spur
或者你也可以使用TMUX到远程服务器上运行命令和你的TMUX seisson会在后台即使运行你退出了shell。您可以在几天后加入该tmux会话并继续执行命令
您可以在Linux中使用screen
,即使在与服务器断开连接后,仍可继续在后台执行此过程。 同样可以使用tmux
。
this问题的答案很可能是你在找什么。
我们用下面的格式来执行远程脚本 ssh -t -t [email protected] 'nohup /path/to/scrip.py'
使用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。
https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session –
[断开后保持SSH会话运行 - 过夜](https: //stackoverflow.com/questions/33205456/keep-ssh-sessions-running-after-disconnection-for-overnight) –