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


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?


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.

Site Moderator
Site Moderator badge
May 21, 2022
Accepted Answer

Hi @hjmeulenbelt,

How do you run the Script? Do you just run python3 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:

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.