citusdata/pg_cron
FreeRun periodic jobs in PostgreSQL
About citusdata/pg_cron
pg_cron is a simple cron-based job scheduler for PostgreSQL (version 10 or higher) that runs inside the database as a PostgreSQL extension. It uses a background worker to track jobs in the cron.job table, supporting standard cron syntax with additional capabilities such as specifying intervals in seconds (e.g., '10 seconds') and using '$' to indicate the last day of the month. pg_cron can run multiple jobs in parallel, but only one instance of each job at a time; subsequent triggers are queued until the current instance completes. Jobs are managed via built-in functions: cron.schedule, cron.schedule_in_database, cron.unschedule, and cron.alter_job. Row-level security (RLS) ensures that users can only see and modify their own jobs, unless they are a superuser or have bypass RLS privileges. This extension is ideal for automating periodic database maintenance tasks directly from within PostgreSQL without requiring external cron daemons.
Key Features
Pros & Cons
- Fully integrated into PostgreSQL – no external cron daemon needed
- Uses familiar and widely supported cron syntax
- Lightweight and simple to set up as a standard extension
- Supports fine-grained scheduling down to seconds
- Open source (licensed under PostgreSQL license)
- Active community and maintained by Citus Data
- Only one instance of a specific job runs at a time; overlapping executions are queued
- Requires PostgreSQL 10 or higher
- Schedule is limited to database-level jobs; cannot directly schedule OS commands
- Second-based intervals cannot be combined with standard cron time fields
- No built-in web UI – management done via SQL