简体   繁体   English

在 ubuntu 服务器上运行 python 脚本并连接到服务器并与脚本交互

[英]Running a python script on a ubuntu server and connect to server and interact with script

I am not sure how to approach this project but my goal is to have a python script constantly running on a ubuntu server in the cloud then being able to connect to my server via ssh and then being able to interact with the python script that is running but i am not sure where to start.我不确定如何处理这个项目,但我的目标是让 python 脚本在云中的 ubuntu 服务器上持续运行,然后能够通过 ssh 连接到我的服务器,然后能够与正在运行的 python 脚本进行交互但我不知道从哪里开始。

use screen or tmux after establishing ssh connection.建立 ssh 连接后使用screentmux

Install tmux (it is usually installed by default) just in case:安装 tmux(通常默认安装)以防万一:

sudo apt install tmux

them run tmux他们运行tmux

Inside the tmux session, you can run the script and interact with it.在 tmux session 内部,您可以运行脚本并与之交互。 Whenever you got disconnected;每当您断开连接时; the script will continue working.该脚本将继续工作。

After re-establishing ssh connection you can do tmux at and continue working with your script and check its log.重新建立 ssh 连接后,您可以执行tmux at并继续使用您的脚本并检查其日志。 For more information on tmux check out this link .有关 tmux 的更多信息,请查看此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM