frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

How to run cron jobs in Postgres without extra infrastructure

https://wasp.sh/blog/2025/05/28/how-to-run-cron-jobs-in-postgress-without-extra-infrastructure
81•Liriel•4d ago

Comments

xnx•1d ago
No mention of pg_cron?
etchalon•1d ago
It's what I expected to be talked about exclusively in the article based on the title.
eddythompson80•1d ago
apples and oranges?

pg_cron is for pg specific cron tasks. You use pg_cron to truncate a table, compute pg views, values, aggregates, etc. Basically just running PG queries on a CRON schedule.

pg_cron itself won't run an external script for you. Like you can't do

    SELECT cron.schedule('0/30 * * * *', $$ ./sendEmails.sh $$);

you can use pg_cron to insert a job-row in a jobs table that you have some consumer that runs a `select * from jobs where status = 'pending' limit 1;`. Then you're on the hook to handle the pg updates for dispatching and handling updates, job status, etc. You could even call that implementation pg-boss if it's not taken.
hoppp•1d ago
There is an HTTP extension for postgres, so it can trigger external serverless functions via http request
cpursley•22h ago
What’s the name of that?
hoppp•21h ago
https://github.com/pramsey/pgsql-http

It works well with Supabase, I tried it, its decent but you should only use it for endpoints you trust because waiting for the request is blocking.

If you want the requests to be async you need to use pg_background extension with it

SoftTalker•1d ago
Cron isn't an acronym; it's not normally written in all caps.

Cron's name originates from Chronos, at least according to Wikipedia.

tbrownaw•1d ago
I can't check at the moment, but IIRC the output of `ps` on $employer's AIX boxes disagrees about it not being all-caps.
NeutralForest•1d ago
Tangential since it's not PG related but I'm more and more moving away from cron and I prefer using systemd timers (I'm on RHEL at work). I just find the interface to list and manager timers better and I can just handle everything like a systemd service anyways.
jimis•1d ago
What is the systemd equivalent for `service crond stop` and later `service crond start`?

In other words, I want to disable all jobs for some time (for benchmarking) and then bring them back up.

sherburt3•1d ago
Maybe you could make a target unit file like “jobs.target” and in your timer unit files do “WantedBy=jobs.target”. Then you could do “systemctl start/stop jobs.target”
r2_pilot•1d ago
First, list and save the currently active timers: ```bash systemctl list-timers --state=active --no-legend | awk '{print $NF}' > /tmp/active_timers.txt ```

Stop all active timers: ```bash sudo systemctl stop $(cat /tmp/active_timers.txt) ```

Later, restart the previously active timers: ```bash sudo systemctl start $(cat /tmp/active_timers.txt) ```

samtheprogram•1d ago
I would try *.timer. If you’re in zsh, quote it.
NeutralForest•1d ago
Like the others said, you have to list them and save it somewhere, it could be better in that regard.
zie•1d ago
I have nothing against pg_boss[0] from the articel (I don't know anything about it), but there are plenty of queues and crons and schedulers for PG

Some others:

* https://github.com/LaunchPlatform/bq

* https://github.com/cybertec-postgresql/pg_timetable

* https://github.com/pgmq/pgmq

* https://github.com/riverqueue/river

* https://github.com/oban-bg/oban

* https://github.com/pgadmin-org/pgagent

* https://github.com/citusdata/pg_cron

etc. There are plenty of options to choose from.

0: https://github.com/timgit/pg-boss

TkTech•1d ago
Gonna toss my own hat in the ring there for the python+postgres ecosystem :)

https://github.com/tktech/chancy

> As a rule of thumb, if you're processing less than 1000 jobs per day or your jobs are mostly lightweight operations (like sending emails or updating records), you can stick with this solution.

This seems... excessively low? Chancy is on the heavier side and happily does many millions of jobs per day. Postgres has no issue with such low throughput, even on resource constrained systems (think a $5 vps). Maybe they meant 1000 per second?

zie•1d ago
I missed that. That does seem very small, 1k jobs/day is nothing.

Chancy also looks pretty neat. Thanks for sharing!

cpursley•1d ago
Also worth mentioning: https://www.pgflow.dev/
wewewedxfgdf•1d ago
There's many ways to skin this cat. Personally I invested all my knowledge and focus into systemd timers. No doubt you have your own ways that make sense for you.
verdverm•1d ago
There's no systemd running in containers, so not an option in a lot of common scenarios
sampullman•1d ago
I haven't done it myself, but it seems possible with Podman or LXC containers. There's systemd-nspawn, too.
hiAndrewQuinn•1d ago
I like systemd when I have it; on the other end is the BusyBox cron implementation https://wiki.alpinelinux.org/wiki/Cron
verdverm•1d ago
I recently used PG-Boss to setup jobs to refresh auth tokens in the background. Very easy to use, would recommend taking a look. Docs are a bit minimal, but there's not that much to it either. (https://timgit.github.io/pg-boss/#/)

You don't need WASP for any of this, certainly not worth learning their custom DSL for it. Two of their points about how it makes it better are moot, setting queue names (one line of code) and type safety (you should be using TS already). I've not seen the value in their abstractions and indirection.

lukasb•1d ago
I can't be the only Next.js / neon user looking at this
mitjam•1d ago
Kubernetes CronJobs are nice and if you are on K8s, already, it’s also without extra infrastructure.
mati365•1d ago
This article seems to be written entirely by AI :/
jbverschoor•1d ago
Cron/systemd/launchd is nice for machine-level tasks.

If you want application or platform level tasks, you’re better off scheduling a task on which ever job queue you run. That could also be pg.

That way you can have platform-wide unique tasks, probably better monitoring / tracing, etc.

jackb4040•1d ago
I have a node app that has one-off scheduled tasks. Between node-cron and real Linux cron, I went with real cron because node-cron just polls every second, which is extremely inefficient and I'm on a free tier.

How does your library work in this regard? If my node server is down, will my scheduled tasks still execute? I notice you have a .start() method, what does that do? Is it polling periodically?

xqzv•20h ago
It's polling using javascript timers: https://github.com/timgit/pg-boss/blob/master/src/attorney.j...
OJFord•17h ago
Or the aptly named pg_cron which is in RDS for example. TFA is just a marketing piece for Wasp, presumably to improve its SEO since 'postgres cron' more obviously gets you to pg_cron otherwise.

Atari Means Business with the Mega ST

https://www.goto10retro.com/p/atari-means-business-with-the-mega
28•rbanffy•2h ago•9 comments

Figma Slides Is a Beautiful Disaster

https://allenpike.com/2025/figma-slides-beautiful-disaster
150•tobr•7h ago•77 comments

Codex CLI is going native

https://github.com/openai/codex/discussions/1174
26•bundie•1h ago•9 comments

The Future of Comments Is Lies, I Guess

https://aphyr.com/posts/388-the-future-of-comments-is-lies-i-guess
41•zdw•2d ago•18 comments

RenderFormer: Neural rendering of triangle meshes with global illumination

https://microsoft.github.io/renderformer/
191•klavinski•9h ago•41 comments

Why DeepSeek is cheap at scale but expensive to run locally

https://www.seangoedecke.com/inference-batching-and-deepseek/
57•ingve•5h ago•37 comments

Progressive JSON

https://overreacted.io/progressive-json/
319•kacesensitive•12h ago•152 comments

I like to install NixOS (declaratively)

https://michael.stapelberg.ch/posts/2025-06-01-nixos-installation-declarative/
72•todsacerdoti•6h ago•37 comments

How Georgists Valued land in the 1900's

https://progressandpoverty.substack.com/p/how-georgists-valued-land-in-the
82•surprisetalk•1d ago•53 comments

Google AI Edge – on-device cross-platform AI deployment

https://ai.google.dev/edge
44•nreece•6h ago•3 comments

Show HN: A Implementation of Alpha Zero for Chess in MLX

https://github.com/koogle/mlx-playground/tree/main/chesszero
33•jakobfrick•3d ago•2 comments

Structured Errors in Go

https://southcla.ws/structured-errors-in-go
65•todsacerdoti•8h ago•25 comments

Father Ted Kilnettle Shrine Tape Dispenser

https://stephencoyle.net/kilnettle
125•indiantinker•7h ago•23 comments

A Pokémon battle simulation engine

https://github.com/pkmn/engine
26•rickcarlino•2d ago•7 comments

Browser extension (Firefox, Chrome, Opera, Edge) to redirect URLs based on regex

https://github.com/einaregilsson/Redirector
31•Bluestein•5h ago•12 comments

Ovld – Efficient and featureful multiple dispatch for Python

https://github.com/breuleux/ovld
74•breuleux•2d ago•22 comments

RSC for Lisp Developers

https://overreacted.io/rsc-for-lisp-developers/
4•bundie•1h ago•6 comments

A Beautiful Technique for Some XOR Related Problems

https://codeforces.com/blog/entry/68953
24•blobcode•6h ago•2 comments

An optimizing compiler doesn't help much with long instruction dependencies

https://johnnysswlab.com/an-optimizing-compiler-doesnt-help-much-with-long-instruction-dependencies/
15•ingve•5h ago•1 comments

When Fine-Tuning Makes Sense: A Developer's Guide

https://getkiln.ai/blog/why_fine_tune_LLM_models_and_how_to_get_started
5•scosman•2d ago•0 comments

Reviving Astoria – Windows's Lost Android

https://trungnt2910.com/astoria-windows-android/
45•upintheairsheep•8h ago•16 comments

Why Use Structured Errors in Rust Applications?

https://home.expurple.me/posts/why-use-structured-errors-in-rust-applications/
28•todsacerdoti•8h ago•16 comments

New adaptive optics shows details of our star's atmosphere

https://nso.edu/press-release/new-adaptive-optics-shows-stunning-details-of-our-stars-atmosphere/
111•sohkamyung•14h ago•13 comments

Snake on a Globe

https://engaging-data.com/snake-globe/
41•rishikeshs•2d ago•10 comments

Show HN: Patio – Rent tools, learn DIY, reduce waste

https://patio.so
133•GouacheApp•12h ago•73 comments

Stepping Back

https://rjp.io/blog/2025-05-31-stepping-back
80•rjpower9000•12h ago•29 comments

Tldx – CLI tool for fast domain name discovery

https://github.com/brandonyoungdev/tldx
42•Brandutchmen•8h ago•18 comments

CCD co-inventor George E. Smith dies at 95

https://www.nytimes.com/2025/05/30/science/george-e-smith-dead.html
117•NaOH•17h ago•10 comments

A Lean companion to Analysis I

https://terrytao.wordpress.com/2025/05/31/a-lean-companion-to-analysis-i/
230•jeremyscanvic•20h ago•23 comments

I like Svelte more than React (it's store management)

https://river.berlin/blog/why-i-like-svelte-more-than-react/
5•adityashankar•2h ago•4 comments