How to run a Python script 24/7 ??

digitalFR

Newbie
Joined
Feb 11, 2022
Messages
35
Reaction score
23
I need to run a python script 24/7, what options do I have? Can I rent a place where the code is being run all the time?
If so, how secure is it? Because I have many logins/passwords of accounts with money in them being stored, will it be safe?

I will also need to run a VPN and some .bat/.json files, will that be possible?
 
Get a VPS or just buy a raspberry pi (even the oldest version or 2nd hand ones should suffice) for a low price and let it run.

If I'm you, I would go with the 2nd option since you're paying a one-time fee and you can do other various python projects in it. It uses very little power too... Just power the tiny device with USB 2.0 power cable. You own the device and you can set up security for it.

VPS, on the other hand, you have to pay it every month. And you don't know how secure it is and whether the provider is reliable.
 
Dockerize it may be? You just need to keep your machine on, or like others have said, use a vps.

If using docker compose, add

restart: always

To the service, and add a delay in the script so that it does not hurt your machine.

Atleast that's how I would do it. :)
 
I'd say buy a VPS from a high reputation vendor (like DigitalOcean, Hetzner or OVH) so you won't have any issues.
A basic 5/10 $ a month service will be enough.
 
I built an api interface that runs python scripts via webbrowser login, works with json too, and it runs on windows server.
 
you can use vps/rdp
 
You can use vps//vds like snel, OVH, etc., security is an individual issue.But using a server is no less secure than using your own PC.
 
Back
Top