Live data from Hacker News

Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

news.ycombinator.com

131–140 of 336 posts

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#131
Google Apps Script and Browserflow are two of my favorites. Getting a GCP or AWS VM is a solid approach too; both have reasonable free-tiers. And as an alternative to cron, the Python `schedule` library is nice too. Finally if you don't mind some down time, running it on your laptop might be fine. Supervisord is a solid tool for keeping jobs running / restarting them on error.

I'm actively using all of the above approaches.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#134
I use Serverless with Lambda. It's even a template in Serverless, so with the CLI you just type `serverless` and select the Node.js/Python Scheduled Task template and everything is set up for you.

I do a lot of web scraping, and Lambdas are very useful for web scraping since their IPs can change for each request.

For deployment, you can just do `serverless deploy` or set up a GitHub action each time you push to main.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#135
How about Kubernetes cronjobs on Spot VM on GKE autopilot? https://cloud.google.com/kubernetes-engine/pricing If your job only consume 1 vCPU/1GB memory, it costs about $10/month. If those jobs only run 1/100 of a month cost should be $0.1/month.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#136
post #108

Most folks here are focusing on the scheduling part, but change detection means you need some way to persist state (or have a long running process that keeps state in memory). While you could do FaaS (e.g. AWS Lambda) + another service for state (e.g. S3/RDS/EFS), that seems like overkill. Even today I would still do it the old way: store state in a filesystem (maybe SQLite if you have more complex needs), and config…

I thought about AWS MQTT "IoT" as the pricing contains gems like a million MQTT packets for a dollar. You'd use a MQTT "retained message", push the current SHA1 hash of the page or whatever will fit (maybe only a CRC32 LOL), then connect an hour later to receive that message containing the hash. The cost would seem to be $1 per 5 years because AFAIK AWS meters on input and output... I'm not bored enough to audit the AWS pricing structure to see if this will work. I think $2 per decade would be hard to beat for a billed service.

I think the cheapest "cheaty" way to store data for free would be to pollute tracking sites. Open an account at some company, change your mailing address every hour, etc.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#137
I'm not sure what you mean when you say there is no easy solution... procure a small vm on Linode or your choice of provider for like $20/mo. SSH into it, set up the crontab to run your web scraping script. I could literally have that set up and running in 15 minutes flat.

EDIT: after reading the other solutions in this thread I'm blown away by how much people are over thinking and over engineering this. KISS people.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#138
post #108

Most folks here are focusing on the scheduling part, but change detection means you need some way to persist state (or have a long running process that keeps state in memory). While you could do FaaS (e.g. AWS Lambda) + another service for state (e.g. S3/RDS/EFS), that seems like overkill. Even today I would still do it the old way: store state in a filesystem (maybe SQLite if you have more complex needs), and config…

> If your answer is: ok, so you just need to create an AWS account, dockerize your script, put it in a Lambda which is hooked up to RDS, trigger lambda through EventBridge and connect it to CloudWatch... then there's something wrong with you. There must be a better way to reliably run a fucking 10 line script in the cloud.

I mean, you don’t have to dockerize it, and I would use S3 or Dynamo for state, but otherwise it’s a pretty simple solution and it can run entirely in the free tier on AWS. It’s way better than managing your own host, especially when you consider that you get monitoring, alerting, logging, etc for free. EventBridge is just the standard AWS thing for triggering stuff (in this case, a cron schedule)—don’t let the branding scare you.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#139
post #57

AWS Lambda and Azure Functions both support timer triggers and probably round down to $0/ month if your job only runs for a few seconds an hour

You get something like a million lambda executions per month in the free tier.

Re: Ask HN: What is the cheapest, easiest way to host a cronjob in 2022?

#140

Fly.io's Machines support cron jobs. You just hand them a Dockerfile and a schedule, and you'll be within their free tier. https://fly.io/docs/machines/working-with-machines/#create-a... See the `schedule` parameter.

I came here to say this!
Post reply on HN