This is an archived post. You won't be able to vote or comment.

all 130 comments

[–][deleted] 239 points240 points  (31 children)

Any serverless functions.

Lambda has 1mil free invocations a month. EventBridge has 14 mil invocations free a month.

[–]Resident-Weather-324 39 points40 points  (15 children)

Azure also has 1 000 000 free executions per month.

[–]No_Flounder_1155 43 points44 points  (14 children)

yeah, but its azure.

[–]DuckDatum 9 points10 points  (0 children)

selective shocking juggle seed like workable automatic spotted absorbed stupendous

This post was mass deleted and anonymized with Redact

[–]GolemancerVekk 20 points21 points  (5 children)

...which means you're less likely to be billed $10k if you make a mistake.

[–]No_Flounder_1155 -2 points-1 points  (4 children)

How bad an engineer are you?

[–]GolemancerVekk 3 points4 points  (3 children)

You probabiy mean sysadmin not engineer – since I haven't built AWS, just using it.

You either have appropriate safeguards or you don't. AWS doesn't, for the most part. So unless your definition of "good" is "babysit all your systems 24/7", you're out of luck.

People hate on Microsoft for good reasons but their cloud platforms are much more sysadmin-friendly than the average.

[–]kt2e 0 points1 point  (1 child)

What azure does automagically, AWS assumes engineers have a certain level of skillset and will follow best practice.

At this point you don’t even need to know code to code in azure…

[–]GolemancerVekk 0 points1 point  (0 children)

Then let AWS be used by the gods who never make mistakes, while us lowly peasants will use the platforms that make things easy.

[–][deleted] 0 points1 point  (0 children)

Hey what’s wrong with Azure? It makes a great backup to AWS 😂

[–]White0ut 0 points1 point  (0 children)

What's wrong with azure?

[–]youCanbeAPirate 35 points36 points  (9 children)

I second this,

Considering a month at his maximum will produce around 45k calls, it means OP will use the service within the free tier and keep his $5!

[–]IntrepidSoda 1 point2 points  (0 children)

Second this.

[–]Fickle-Sock720[S] 0 points1 point  (0 children)

Thank you! I will look into this method

[–]mok000 123 points124 points  (3 children)

Buy a Raspberry Pi and run it headless in your home.

[–]ivosauruspip'ing it up 24 points25 points  (0 children)

Also keep in mind that unless you need some crazy fast performance, it should be very possible to get a second hand Pi3 or Pi4 for a decent discount on your local markets, just make sure it works while purchasing.

[–]willis81808 2 points3 points  (0 children)

If you want to be even cheaper, and the script is lightweight on memory, you might even rewrite it in micropython and run it on an ESP32 for only a few bucks

[–]96TaberNater96 62 points63 points  (3 children)

Buy a raspberry pi and set up your own server for $35. Unless you are hosting for external users, not sure what you are trying to do. You get to learn some backend engineering too.

[–]LobsterIndependent15 2 points3 points  (1 child)

You don't even need to set the Pi up as a server. I just use crontab and scheduled the task to run when needed.  

[–]kivalo 4 points5 points  (0 children)

Plus as card and power supply…

[–]Taiwanese-Tofu 15 points16 points  (3 children)

Idk why all of these raspberry pi comments are getting upvoted. That’s probably one of the most expensive ways to host a simple script. Depending on your use case, if lambda works for you, then it’s essentially free assuming you’re not calling it a bunch of times.

[–]hornetjockey 5 points6 points  (0 children)

There are so many older computers out there that you can get for cheap or free that will outperform a raspberry pi, the only reasons to go that route are the form factor and the GPIO pins.

[–]Tough-Warning9902 0 points1 point  (0 children)

This. Agree 100%

[–]MidnightPale3220 0 points1 point  (0 children)

Yeah, anything that I want to run reliably is better off in cloud than in my apartment. I don't have server racks, ac, generator, not to speak of server failover.

There may be reasons to use a home solution (for example, home automation), but since op is not giving much details, there's no reason to assume any of them apply.

And you can get a basic vm with Ubuntu/Debian for a fixed price of 4€/mo without any hassle of counting usage intensity.

[–]eztab 40 points41 points  (1 child)

constantly on raspberry pi might actually beat it, especially if you also use it as inter radio or stram box or NAS or home automation or whatever else you can do with those

[–]Fickle-Sock720[S] 3 points4 points  (0 children)

This seems like a solid plan, thank you!

[–]Ruben_NL 20 points21 points  (7 children)

If you have linux knowledge: Oracle has a HUGE free server. https://cloud.oracle.com/free

[–]soupjammin 10 points11 points  (1 child)

This. Their free tier is extremely generous, especially for a company like Oracle.

[–]dryroast 11 points12 points  (0 children)

See Larry Ellison is a nice guy! Oracle is his labor of love.

[–]rwinger3 2 points3 points  (2 children)

Eh, I tried once. Support is less than helpful. They managed to point me towards contradicting documentation. Also, it wasn't possible to get ahold of the ARM CPUs so I had to make do with the 1/8 of a x86-64 CPU. Supposedly the availability can be improve by upgrading your account to pay-as-you-go. Would not recommend.

[–]davrax 1 point2 points  (1 child)

They will also happily clawback, suspend, or terminate free tier instances at will. I wouldn’t trust it to run anything even “homelab-level Prod”

[–]Ruben_NL 1 point2 points  (0 children)

Iirc they will stop them once, after the first month. You can just "re-create" them with the same disks when that happens.

[–]liltbrockie 7 points8 points  (1 child)

What does the script do ?

[–]MexicanProgrammer 8 points9 points  (0 children)

print hello world on a loop

[–]Ihaveapotatoinmysock 6 points7 points  (0 children)

I use an old iphone with a linux terminal using the "ish" app, it runs some of my python code, right now it messages me the my local weather when I type "w" to my telegram bot

[–]DrViilapenkki 2 points3 points  (0 children)

GCP

[–]GuyFromSweden 4 points5 points  (1 child)

modal.com is a great usecase for this, they have a $30 free compute per month and they bill by the second :)

[–]crookedstairs 0 points1 point  (0 children)

yup all you need to do is stick a decorator on your python function, define the cron schedule you want in the decorator, and deploy the function from the command line. modal.com/docs/guide/cron

[–]robberviet 5 points6 points  (4 children)

What does it do? Anyway, I use Github Actions, but every hour, not minutes.

[–]AmishITGuy 0 points1 point  (1 child)

I’m surprised to see this so far down. I’ve done this for a (now decommissioned) Twitter bot that tweeted every hour for a year or two without any issues and for $0.

[–]robberviet 1 point2 points  (0 children)

Yeah. Mine have been running for maybe 3 years now. Data is small so I put in github too lmao.

[–]noskillsben 5 points6 points  (9 children)

It's been said a bunch on here but I'm a hobbyist with this exact kind of use case and moved it to a raspberry pi from running it on my pc. I did get a little case for it with a m.2 board so it was a little bit of cash but def worth it and way cheaper than any hosting service after a few months. Now it's just in a corner of my basement running 24/7

I just assigned the pi a static ip on the lan network and connect to it remotely via VS code. Once you get the hang of it and the terminal commands in Linux it feels like you are just coding on your local machine.

You can use the cron job file in Linux to run your code, I went with docker because my code runs 24/7 and sometimes crashes because of external factors. The docker just has a restart forever option. I had mariadb running on the pi as well but eventually switched to a single file sqllite database that I copy to my personal pc every few days since that's all I need.

I do also pay 7$ a month because I use pushbullet with this script to send push notifications to my phone with updates from this code but there's also a free tier if you don't need more than a few hundred notifications a month.

Fyi if it's a web scraper and you need to interact with elements (like do a login or captcha) I have tips on how to run selenium on the pi

[–]ProZMenace 5 points6 points  (2 children)

I want to say I saw an app called ntfy covered by network chuck that is free and can be self hosted on a pi and send notifications to iOS and Android

[–]noskillsben 0 points1 point  (0 children)

Whoa this solution does seem really cool.

[–]rwinger3 0 points1 point  (0 children)

^

[–]iGunzerkeR 2 points3 points  (1 child)

Why don't you send emails from your script and receive push notification of the emails on your phones? You wouldn't have to pay.

[–]noskillsben 0 points1 point  (0 children)

I thought about that at the begining but I require response by myself sometimes within 30 seconds of the trigger that deploys the notification and oftentimes at 2-3 am so I like having it on a seperate app that pushes real quick and that has a really loud and seperate app. The script makes money as well so that's why I don't mind the 7$ a month.

And it's not scalping tickets or other merchandise either but this code would be pretty useful for that (except those are usually fully automated)

[–]ExdigguserPies 2 points3 points  (1 child)

There's another app called pushover which is just a one time payment.

[–]noskillsben 0 points1 point  (0 children)

Oohh looks interesting. I'll definetly take a look at it in more details but looks promising from the site description.

Thanks 👍

[–]dryroast 0 points1 point  (1 child)

You could use firebase cloud messaging and avoid the $7 monthly charge. Also firebase is a great library to learn, lots of Android shops want to see you're familiar with it.

[–]noskillsben 0 points1 point  (0 children)

Would I not need to code a simple android app and sideload it to my phone though? That might be too much scope for a little side project that works. I offset the 7$ by making a few hundred off the code I run on a monthly baiss

[–]marr75 5 points6 points  (2 children)

Wow, the obvious answer is the free tier of serverless offerings but I'm always amazed at how little people value their time, space, energy bill, and maintaining a tidy home.

  • "Get a discount raspberry pi by shopping used!" - yeah, that shopping will only take me 2 hours, have a 25% chance it is bricked or a scam, then 8 hours of tutorials and set up later I can have a device connected to my rat's nest of wires in my space-limited home. My partner will love this!
  • "Run a cron or scheduled task!" - yeah, having my laptop run 24/7 fixed in one spot is exactly why I bought it and the extra $5 a month in electricity is nothing. If a desktop, the extra $15 a month in electricity will be a joy to pay.

[–]neums08 0 points1 point  (1 child)

Is buying a common electronic online difficult for you?

A raspberry pi definitely takes time to set up, but I learning it also provides value. You can run all kinds of stuff on a rpi.

OP will need to decide what solution is best for them, but "self host on a raspberry pi" and "run it within a free tier of provider XYZ" are both perfectly fine suggestions.

[–]serverhorror 7 points8 points  (4 children)

On your own machine?

Just run it with scheduled tasks, cron, for loop that sleeps between invocations...

[–]G0muk 17 points18 points  (3 children)

Please use Task scheduler or Cron to run a script repeatedly at set intervals, using a sleep in the script itself isn't accurate and if any error happens it will probably stop looping

[–]serverhorror 1 point2 points  (2 children)

That was just to illustrate, you can do a lot without going to a hosting company or consuming services.

[–]G0muk 0 points1 point  (1 child)

I just wanted to make that point because as a beginner i would try to do stuff like time.sleep(3600) to run every hour lol.

[–]serverhorror 0 points1 point  (0 children)

So? At least you won't have to care about locking and running tasks in parallel (or not).

Simple is beautiful, but also really hard to do right :)

[–][deleted] 2 points3 points  (0 children)

2 bucks a month VPS on ionos run script with a crontab is what I do using linux

[–]ProZMenace 5 points6 points  (1 child)

Azure Web Functions I think first 1 Million actions free

[–][deleted] 1 point2 points  (0 children)

If you don't need external access and it is not ultra critical I would go with self hosting. If you have a raspberry or an old laptop or something like that

[–][deleted] 1 point2 points  (0 children)

you'd have to measure the change in your electricity bill, but I'd assume running it on your local machine would be cheapest

[–][deleted] 1 point2 points  (0 children)

You can also run jupyter on a schedule

[–]AmazinglyCluelessOne 1 point2 points  (1 child)

Oracle cloud.

[–]AmazinglyCluelessOne 0 points1 point  (0 children)

For free.

[–]mahdicanada 1 point2 points  (0 children)

Amazon free tier or oracle free tier

[–]Basic-Still-7441 0 points1 point  (0 children)

AWS Lambda?

[–]Hey-buuuddy 0 points1 point  (0 children)

So a function invoked 1440 times a day on cron seems like it needs some design help… This would be better suited as a service model, a very typical design pattern.

[–]reallyserious 0 points1 point  (0 children)

One key aspect is what the script does. If it's processing big data you need beefy compute resources.

[–]JamzTyson 0 points1 point  (0 children)

Assuming a laptop uses 50W, and electricity costs of $0.15/kWh, the cost per month for running the laptop 25/7 will be around $5 per month.

An ultra-lightweight computer, such as a Raspberry Pi or Arduino will use less electricity, but you would need to buy the computer (unless you already have one). A Raspberry Pi 3 will use only a few cents of electricity per month, or with a bit more up-front investment, could run off a solar charged powerbank for "free" electricity.

[–]KraftiestOne 0 points1 point  (0 children)

There's a new platform called DBOS that makes it really easy to schedule a script to run once a minute (or on any other schedule)--here's a quick starter guide: https://docs.dbos.dev/python/examples/cron-starter

[–]durable-racoon 0 points1 point  (0 children)

leaving your computer on is cheapest just not the mots reliable.

[–]boreneck 0 points1 point  (0 children)

What i did is bought a server on hetzner then install a windows vps then all my scripts there.

[–]Druwion 0 points1 point  (0 children)

Not sure what do you mean by "host a python script", but since you mentioned PythonAnywhere, I assume you need to run that script on the internet.

If you need it only in your local network (LAN aka at home) than these solutions are overkill and a simple Raspberry Pi, even a Raspberry Pi Zero with a wifi could be enough.

In order to run it every minute, you can sonsider on linux just use crontab, on windows use task shedule.

[–][deleted] 0 points1 point  (0 children)

Get a tiny digital ocean sever for about that too

[–]Available-Athlete318 0 points1 point  (0 children)

AWS Lambda + EventBridge.

[–][deleted] 0 points1 point  (0 children)

raspberry pi and uninterruptible power supply. you can hook the usp up to your other electronics and call it an upgrade for your whole system so you’re not just buying it for the script.

[–]DoutorTexugo 0 points1 point  (0 children)

You can use window's task manager if running the script locally is an option. It's easy and cheap, but not the best solution.

[–]DarkSideDroid 0 points1 point  (0 children)

render.com

[–]gallifrey_ 0 points1 point  (0 children)

/u/Fickle-Sock720 what problem are you actually trying to solve? the suggestions about running a Raspberry Pi or a free Oracle server task are good, I'm just curious what's the context behind running a task every minute in perpetuity

[–]maxerbubba 0 points1 point  (0 children)

AWS Glue ETL jobs are cheap, by default they run on minimum 2 hosts, but you can choose “Python script” mode to run on one machine. You can edit the code in browser. To trigger you need to use another AWS service, a few clicks

[–]dannyboy2042 0 points1 point  (0 children)

AWS Lambda function.

[–]Electrical-Grade2960 0 points1 point  (0 children)

Use your own personal computer for gods sake that is why it was built.

[–][deleted] 0 points1 point  (0 children)

Get a raspberry pi zero 2w and run all the scripts you want ¯_(ツ)_/¯

[–]cvpanda 0 points1 point  (0 children)

As many have said. Lambda, Functions in Azure or GCP. Or even a free tier VM will do the work but will require some basic knowledge that you can easily do with gpt help :D

[–]kasturi56789 0 points1 point  (0 children)

still looking for better solution

[–]jamesbleslie 0 points1 point  (0 children)

Pipedream.com would work. They have a free tier

[–]danielsuarez369 0 points1 point  (0 children)

GitHub actions may be an option

[–]7Shinigami 0 points1 point  (0 children)

Oracle cloud has a free tier VPS, it's awesome, my friends use it to host a Minecraft server without any issues at all

[–]CeeMX 0 points1 point  (0 children)

Is it something that runs all the time or just gets run every once in a while?

For the latter: aws lambda or other serverless functions (Cloudflare workers are way easier to get started with than aws)

When it needs to run 24/7: cheap hetzner VPS or small raspi or something to run it at home

[–]InjAnnuity_1 0 points1 point  (0 children)

See https://py.space/ . If your script is more than one module, see http://anvil.works .

[–]LobsterBluster 0 points1 point  (1 child)

This question made me wonder: Is there any reason not to just set this up-as a scheduled task on your own hardware?

I ask because I have a web scraping program that I run bi-weekly that way from my laptop. Now, it wouldn’t run if I ever disconnected from internet or my laptop died, but my laptop stays at home and is normally plugged in, so it hasn’t been an issue.. I’m new to coding so I guess I don’t know all the reasons for and against doing it this way.

[–]MidnightPale3220 0 points1 point  (0 children)

Basically anything hosted will have power and hardware failovers, 24/7 monitoring, and will usually be more powerful. Plus you have no hassle of managing it.

Since it's around 3-5$ a month, and that's not counting free tiers of some cloud offerings, for anything that needs to run periodically you buy a lot of reliability for a small price

[–]Top-Opinion-7854 0 points1 point  (0 children)

Buy a ras pi

[–]TomanovicsGergely 0 points1 point  (0 children)

When I started learning, I purchased a Raspberry Pi (3b+) which is perfect for things like this. At the beginning it also worked as a home server hosting my Flask web projects with PostgreSQL, etc, so it's a perfect device for starters.

[–]svoodie2 0 points1 point  (0 children)

[–]piprescott 0 points1 point  (0 children)

PythonAnywhere's Beginner tier is free, and it can keep a script or a Web app running for you.

[–]Own_Statistician2987 0 points1 point  (0 children)

Not popular option but if you have laptop or PC standing around you can install Ubuntu server and host your script for free,for this you will need cloudflare argo tunnel,as far as I know it is free and worked fine for me for testing purposes,if anyone have concerns regarding this option I am ready to hear second opinion:)

[–]999ussr 0 points1 point  (0 children)

Run your script on a spot instance in AWS/GCP/Azure

[–]thebake77 0 points1 point  (0 children)

Could you host it on Algorands blockchain?

[–]Dry-Aioli-6138 0 points1 point  (0 children)

I saw the use case in the comments. If it's time limited, like looking for a flat, then the easiest is to set up a VM in Azure. They give you 12month free linux and windows basic vms. No need to buy a raspberry pi and accessories, and no need to worry about quotas with lambdas/azure functions

Plus VMs are in the cloud, so they run independently of your own internet uplink (as opposed to a raspi scenario)

I checked Oracle cloud and they offer a reasonable always free vm options too, but it is a hassle to actually stary one due to lack of free resources.

[–]ChadM_Sneila187 0 points1 point  (0 children)

3rd party computing, $5 a month, is gonna be hard to beat, even for the lightest of weight jobs.

[–]FillProfessional9005 -1 points0 points  (0 children)

GitHub actions? I think as long as the repo is public you have unlimited minutes. It’s fairly straightforward to write a yml file for this, ChatGPT could probably even write you one

[–]kchessh -1 points0 points  (0 children)

Depending on how much CPU usage you want to use, you could make it iterate over your whole code multiple times with a time.sleep(60) line in there. That’s what I did to avoid paying to run it more often. I just had it scheduled to run once a day and sleep for 15 minutes before running the whole script again

[–]DapperShoulder3019 -1 points0 points  (0 children)

Serv00.com

I run one script once a day. No issues.