简体   繁体   English

如何让 python 脚本 (abc.py) 在连接丢失或 SSH 连接终止后继续在 AWS 上执行?

[英]How to let the python script (abc.py) keep executing on AWS even after Connection lost or SSH connection is terminated?

I was using Jupyter notebook on AWS AMI and using the port forwarding on Windows using PuTTY .我在 AWS AMI 上使用Jupyter notebook ,并使用PuTTY在 Windows 上使用端口转发。 I got my connection terminated and all the work of 24 hours is lost now and I'm unable to get that.我的连接被终止了,现在 24 小时的所有工作都丢失了,我无法得到它。 So I used a script instead of Notebook and the same thing happened.所以我使用了一个脚本而不是笔记本,同样的事情发生了。 I used to think that the process would keep going on even if the Shell connection is lost.我曾经认为即使Shell连接丢失,该过程也会继续进行。 But next time I login, I don't see anything.但是下次我登录时,我什么也看不到。 I used top , htop aux to find if my processes are still running but they don't show my process.我使用tophtop aux来查找我的进程是否仍在运行,但它们没有显示我的进程。 Please help how can I stop this from happening.请帮助我如何阻止这种情况发生。

I am using Windows on 10 with Putty on local and Ubuntu 18 on the AWS AMI.我在 10 上使用 Windows,在本地使用Putty ,在 AWS AMI 上使用Ubuntu 18

You can try你可以试试

nohup python3 myscript.py &

Try the tmux试试 tmux

apt install tmux

I often use it to keep my web runing on server(not professional but convenient)我经常用它来保持我的web在服务器上运行(不专业但方便)

You can use screen.你可以使用屏幕。

You can install it wit:你可以安装它:

sudo apt install screen

You can find more information right here: https://linuxize.com/post/how-to-use-linux-screen/您可以在这里找到更多信息: https://linuxize.com/post/how-to-use-linux-screen/

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

相关问题 如何将 AWS lambda 增加到 lambda 连接超时或保持连接有效? - How to increase the AWS lambda to lambda connection timeout or keep the connection alive? 远程连接/SSH 连接到已部署的 AWS AppRunner 容器 - Remote connection / SSH'ing into a deployed AWS AppRunner container AWS Lambda javascript 保持与第三方的连接 API - AWS Lambda javascript keep alive connection to third party API Npm 在 SSH 连接后在服务器后台启动 (EC2) - Npm start in background on a server after SSH connection (EC2) 如何抽象 AWS Lambda 中的数据库连接? - How to abstract DB connection in AWS Lambda? 如何向数据库发出我失去连接的信号 - Java - How to signal to the database that I have lost the connection - Java 当 SSH 在本地机器上终止时,让 jupyter lab notebook 保持运行? - Keep jupyter lab notebook running when SSH is terminated on local machine? Github 操作:因“失去连接”而失败 - Github Action : failed with "lost connection" Flutter sign in with google lost authentication 当inte.net连接丢失时,如何重新授权? - Flutter sign in with google lost authentication when the internet connection lost, how to re-auth it? 通过 SSH 隧道连接 DBeaver - DBeaver connection via SSH tunnel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM