Nick Sahno
Nick Sahno

Reputation: 53

Running python script in background EC2

I have a code.py script that I want to run on my Linux EC2 instance. I want it to run even when the tab of the EC2 instance in my browser is closed, so that the code is running in the background.

Is there any way to do this?

Upvotes: 2

Views: 1926

Answers (1)

rezshar
rezshar

Reputation: 620

this command run your python file on another screen that called YourScreenName.

screen -dmS YourScreenName python3 code.py

if you close EC2 instance tab on your browser, this screen will be running on your server.

for access to this screen you can use this command.

screen -r YourScreenName 

and for quit from this screen use Ctrl + a + d

Upvotes: 5

Related Questions