Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

I have a python script that basically runs forever and checks a webpage every second and notifies me if any value changes. I placed it on an AWS EC2 instance and ran it through ssh. The script was running fine when I checked after half an hour or so after I started it.

The problem is that after a few hours when I checked again, the ssh had closed. When I logged back in, there was no program running. I checked all running processes and nothing was running.

Can anyone teach me how to make it run forever (or until I stop it) on AWS EC2 instances? 

I used the Java SSH Client provided by AWS to run the script

1 Answer

0 votes
by (44.4k points)

The Linux screen tool increases your productivity by using multiple windows within one SSH session and will mainly save you from disconnection issues. To install screen:

sudo apt-get install screen

Starting a new session:

screen -S <screen_name>

Run your processes normally in those sessions, and to come back to your main terminal, press ctrl+a+d or type this:

screen -r <screen_name>

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories

...