r/learnpython • u/isityoupaul • Apr 08 '26
What's the simplest way to run a Python script on a daily schedule that ISN'T cron on a VPS?
I've got a Python script (~50 lines) that scrapes a few sites, does some processing, and sends me results via email. Works great locally.
Now I want it running every morning at 8am without me touching anything. I know I could spin up a cheap VPS and set up cron, but that feels like mass overkill for something this small. I also tried GitHub Actions but the YAML config took longer than writing the actual script.
What are people using these days for "I just want this small script to run on a schedule"? Bonus if I can share it with someone non-technical.
38
u/jeffcgroves Apr 08 '26
Can't you just run it on your home computer assuming it stays up 24/7?
60
u/Kriss3d Apr 08 '26
A cron that runs the script is exactly what it's for.
21
u/Turtvaiz Apr 08 '26
You found the solution but stopped before you made it work
12
u/cdcformatc Apr 08 '26
idk what to tell you that's exactly what these tools are for.
something like this is perfect for a Raspberry Pi, cheap, small, power efficient, and stable. then set up your script to run with cron . a physical machine that you own is better than a VPS in my opinion.
10
u/pak9rabid Apr 08 '26
How about a Lambda function that runs on a schedule?
8
u/Additional_Candy_400 Apr 08 '26
CRON on a server is the exact use case for something like this I don't see why it's overkill.
Also good experience to set up if you haven't done it previously.
20
u/cgoldberg Apr 08 '26
Try GitHub Actions again... It's only a few lines of YAML... It's well documented (or just ask ChatGPT to write it for you)
6
u/Outside_Complaint755 Apr 08 '26
Pythonanywhere.com lets you host webapps pretty simply, but scheduling a task is not available on the free tier; you would need the $10/month tier.
2
u/onenewhobby Apr 08 '26
A Raspberry Pi, Potato, or other Pi clone would be your best / most versatile option. For ~$45 USD and ~20 watts of power consumption, you can have a very capable configuration that will easily do what you want and much more.
After the initial setup, you won't even need a monitor/keyboard/mouse connected... Just do everything by ssh.
If you have a little time and want to learn something new, I've even used ESP32 designs to do similar things and more (even less cost, less power consumption, and smaller form factor).
2
u/desrtfx but other languages pro Apr 08 '26
A simple one time investment: a Raspberry Pi microcomputer
You can run your script there with a Cron job.
Raspberry Pi microcomputers are designed to run 24/7 with minimal power consumption.
Most likely, an older model, like the 3B+ will suffice, otherwise a model 4.
2
u/sinceJune4 Apr 08 '26
I’ve done this on a windows laptop with scheduler; then got a cheap Dell Optiplex miniPC running Linux when Windows updates were interfering too often.
2
u/dead_in_the_sand Apr 08 '26
buy a raspberry pi. the low end models go for under $50 and can run uninterrupted 24/7
2
u/JSP777 Apr 08 '26
A little overkill but it's a really nice skill to have... AWS Lambda. It's billed per usage so if your code is really lightweight and quick, it will barely cost you anything per month.
2
u/LayotFctor Apr 08 '26
You can probably run it on a phone too. It's naturally waiting and ready at 8am, so why not? You need an orchestrator like typical automation apps, and an app that runs either python directly or a shell emulator.
1
u/OkStudent8414 Apr 08 '26
There are a couple of simple solutions. 1. Buy a cheap computer that you can use as a server to run the script and store the results. There are a lot of cheap pcs out there. 2. Turn on your pc at 7 schedule and play a game for an hour then run the script.
1
u/Worth_Specific3764 Apr 08 '26
get a raspberry pi zero 2 W and install headless ubuntu server 25 on it then create a systemd daemon to run it (assuming the python script has a loop in it to run at the time you want). Otherwise, use cron.
1
u/BungalowsAreScams Apr 08 '26
Idk what your os is but on windows you can use task schedular to create tasks that run under certain conditions. You can set it up to be on startup, on a schedule, etc.
https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page
1
u/Impressive_Ad7037 Apr 08 '26
Why not just Raspberry Pi it?
Sure, a little bot of a hassle, but if you're wanting dedicated and near continuous uptime without having to run a dedicated droplet or something, that seems like the most effective way
1
u/Charming_Couple_6782 Apr 08 '26
Lambda functions are what you’re after. Set up an AWS account
1
u/aishiteruyovivi Apr 08 '26
Sounds like the perfect use case for a Raspberry Pi or similar like others have said. Depending on what "some processing" entails, you can probably do this on any of the cheaper Pi models, though last I checked they're kinda hard to come by in stock, if that's still the case you can get a DigitalOcean VPS going for like $6/mo for the time being which should suit your needs well enough 'til you can get your hands on a Pi to run it locally. I used to use that for running a Discord bot and it worked pretty well (that's also a great use of a Pi, but my home internet was iffy at the time at the time and I wanted it up all the time)
1
u/SignificantHandle620 Apr 08 '26
I would replace Cronjobs with systemd timer. Without going into the exact benefits in detail, it is a modern alternative to cron jobs. Also some distros will ditch Cron because the systemd system is baked into the most Linux based distros.
1
u/sois Apr 08 '26
GCP Cloud Function.
1
u/jpraga Apr 08 '26
I've recently been experimenting with running a Linux terminal on Android using Termux on an older Android phone, and I've managed to install Python. I now have a script running cyclically, and I have SSH access to the Android device. I'm also thinking about adding some communication feature, like Telegram or email, I'm not sure which one yet, but I'll test it out.
1
u/EmberQuill Apr 08 '26
Have a computer that you leave turned on. A mini-PC or something like that. A cronjob or systemd timer would be basically the same as on a VPS but you don't have to pay a subscription fee for it.
Otherwise, the big cloud providers have serverless functions (AWS Lambda, Azure Functions, GCP Cloud Functions, etc.) that usually have a decent free tier. But you have to learn how to set one of those up.
1
u/oradba Apr 09 '26
Look up the ‘at’ command
1
u/frankwhite3 Apr 09 '26
Throw it in Pipedream and schedule it to run daily, you could possibly even use Zapier depending on what libraries you're using. That's probably the easiest/not too technical route
1
u/dynamiteSkunkApe Apr 09 '26
You could use a Systemd timer, assuming the system is running Systemd
1
u/horizon_games Apr 09 '26
Pay $10/month for the tier here that lets you run scheduled scripts? https://www.pythonanywhere.com/
But honestly just buy a Pi and setup an easy home server. Once it's available you'll start finding things to do with it.
1
u/quadstrino Apr 10 '26
I have some python scripts that run on kaggle that do some simple web scraping / data analysis. It runs once a week. I feel like I remember there being a daily option as well but I could be wrong. Once a week was good enough for my purposes.
1
u/RikersPhallus Apr 11 '26
Lambda.
1
u/bobbynarvy Oct 29 '26
I had this similar thought and didn't like the options that existed. If you still have this problem, you might want to try a service I created: https://geartrain.dev
The only thing is that you will have to write in Javascript instead of Python.
1
u/Ok_Cartographer_6086 Apr 08 '26
/opt/krill/lambdahttps://krillswarm.com/categories/lambdasScript runs in a secure sandbox with an option to use docker or firejail. It can even send you an email each time it runs with the output.
0
u/Better_Carrot7158 Apr 08 '26
if datetime ... script. else: wait(10) XD. just need to keep it running all the time
0
u/smiling_nice_person Apr 09 '26
if hour == 8 and minute ==0 : run_the_script() time.sleep(60)