Question

Python scripts stops when I exit the Console

Hi all,

I have a Droplet with the following specifications:

4 GB Memory / 50 GB Disk / AMS3 - Ubuntu 20.04 (LTS) x64

When I access the Console with my non-root username I run the python script using

python3 scheduler.py

The script should run all day but as soon as I exit the Console (or Terminal), the scripts stops. I know this because there is no new data added to my database. The same script works fine when it runs on my local computer. What am I doing wrong or which settings should I change?

Thanks


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi @hjmeulenbelt,

How do you run the Script? Do you just run python3 scheduler.py in your Terminal, do you add a Screen session or use PM2? If you are not, there are a couple of ways to go.

The first and easiest to go is, to open a Screen session in your Terminal to start the scrip and then detach from that Screen session. Take a look at the following tutorial:

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-screen-on-an-ubuntu-cloud-server