Postgres as a CRON Server
Postgres can act as a cron server by combining the pg_cron extension for scheduling with the pgsql-http extension for outbound HTTP calls, letting a scheduled SQL statement POST to a webhook every minute. The walkthrough covers enabling both extensions, granting cron schema access to non-superuser roles, cron syntax, and inspecting or unscheduling jobs via cron.job and cron.job_run_details. pg_cron runs jobs in background workers so slow endpoints don't block core Postgres, but setting http.timeout_msec to fail fast is still recommended. Suggested uses include batching welcome emails, aggregating data and deleting old rows.
Related posts
- Run Scheduled and Recurring Tasks with Cron
Railway mediumAdeptCron runs commands on time-based schedules but keeps no job history, has no retries and does no concurrency control, so reliability depends on the job itself. The guide covers the five-field schedule syntax, including the day-of-month/weekday OR pitfall and timezone/DST issues, and recommends idempotent upserts, structured start/success/error logs, explicit connection cleanup, and Postgres advisory locks to prevent overlapping runs. On Railway, cron triggers a service's start command in UTC with a 5-minute minimum interval and a single active execution. A process left alive by open handles or pending promises causes later runs to be skipped.
- Your Neon Functions can now run on a schedule
Neon mediumAdept
Neon Function Triggers let Neon invoke a deployed Node.js function on a cron schedule. Because the timer lives outside the Postgres compute, scheduled jobs keep working with scale to zero, unlike pg_cron, which only runs while the compute is up and can only execute SQL. Triggers are branch-scoped, and child branches inherit their parent's triggers in a disabled state, so branching production doesn't double-fire jobs. A worked example uses a Hono handler that verifies the X-Neon-Trigger-Invocation-Id header, reads scheduled_at from the request body, and uses ON CONFLICT DO NOTHING to stay idempotent, plus the API call that creates a 15-minute schedule.
- How to fix missing table errors in pg_cron
Neon mediumAdept
pg_cron stores scheduled jobs as raw SQL text, separate from Postgres' system catalogs, so dropping a table leaves jobs that fail every run with "relation does not exist" and fill cron.job_run_details with errors. Manual unscheduling, defensive DO blocks and cleanup jobs all leave gaps. A roughly 30-line PL/pgSQL event trigger on sql_drop closes them: it calls pg_event_trigger_dropped_objects() and unschedules any cron.job whose command mentions the dropped table name. The post also lists operational practices, such as explicit statement_timeout, setting search_path, and purging run history, and says when Airflow or Inngest fit better than pg_cron.
- Updates for Supabase Functions
Supabase mediumAdeptSupabase is shipping Database Webhooks in alpha, a convenience wrapper around Postgres triggers that fires asynchronous HTTP requests on INSERT, UPDATE and DELETE with a Realtime-style JSON payload. It also adds dashboard editors for Postgres functions and triggers, and lays out a staged roadmap toward its own serverless Supabase Functions. The networking layer is pg_net, a new Postgres extension that queues requests to a background worker using the libcurl multi interface. Queuing 10 GETs returned in 1.5 ms versus 3.5 s for the synchronous pgsql-http, and the extension handles over 300 requests per second.
- Processing large jobs with Edge Functions, Cron, and Queues
Supabase mediumAdeptLarge data-processing jobs on Supabase can be split into a three-layer pipeline: cron-triggered Edge Functions collect work, distributor jobs route it into per-source Postgres queue tables, and specialized workers process one item at a time to stay within serverless timeouts. The worked example is an NFL news aggregator that scrapes sites, classifies articles with OpenAI, upserts player and team entities, and stores pgvector embeddings for search. Key practices include letting unique constraints handle deduplication, always marking queue items processed in a finally block to avoid infinite retries, reporting failures to Sentry, queuing user interactions for batched trending updates, and offloading expensive work like embeddings to background tasks.