Deshwal
Deshwal

Reputation: 4152

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. I got my connection terminated and all the work of 24 hours is lost now and I'm unable to get that. 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. 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. 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.

Upvotes: 0

Views: 149

Answers (3)

Dominik Miskovic
Dominik Miskovic

Reputation: 87

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/

Upvotes: 0

Gary Ong
Gary Ong

Reputation: 1008

You can try

nohup python3 myscript.py &

Upvotes: 1

苏小刚
苏小刚

Reputation: 36

Try the tmux

apt install tmux

I often use it to keep my web runing on server(not professional but convenient)

Upvotes: 0

Related Questions