# pg_cron

> Run periodic jobs in PostgreSQL

Source: https://talira.ai/catalog/pg-cron-ps4nb6wg
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Plugin
- Categories: [databases / postgres / scheduling](https://talira.ai/categories/databases/postgres/scheduling), [databases / postgres / extensions](https://talira.ai/categories/databases/postgres/extensions)
- Platforms: linux, macos, windows[^3][^5]
- Licence: PostgreSQL[^4]
- Pricing: Free and open source[^4]
- Free tier: yes[^4]
- Self-hostable: yes[^3]
- Backed by: [Citus Data](https://talira.ai/orgs/citus-data.md)

pg_cron is a cron-based job scheduler for [PostgreSQL](https://talira.ai/catalog/postgresql-cm55wcnd.md) (10 or newer) that runs inside the database as an extension, made by Citus Data. A background worker reads jobs from the `cron.job` table and runs each one's SQL command (a statement such as `VACUUM` or `DELETE`, or a function or procedure call) on standard cron schedules, with `$` for the last day of the month and intervals down to every second. It runs different jobs in parallel but only one instance of each job at a time, records runs in `cron.job_run_details`, and can schedule jobs in another database of the same server. Managed services including [Amazon RDS](https://talira.ai/catalog/amazon-rds-my1p654h.md), [Supabase](https://talira.ai/catalog/supabase-524j51hm.md) (whose Supabase Cron is built on it), [Neon](https://talira.ai/catalog/neon-62ajbpbj.md), [PlanetScale](https://talira.ai/catalog/planetscale-e7z32n33.md) and [Ubicloud](https://talira.ai/catalog/ubicloud-swceh8m1.md) document it as a supported extension.

## Links

- GitHub: https://github.com/citusdata/pg_cron

## Ways to install

### Package managers

- [Homebrew](https://talira.ai/catalog/homebrew-djy17yn9.md): <https://formulae.brew.sh/formula/pg_cron>[^1]
- [APT](https://talira.ai/catalog/apt-d7essv0z.md): <https://packages.debian.org/source/stable/pg-cron>[^2]

## Problems it solves

- delete old rows from a Postgres table every night without a separate cron server
- schedule VACUUM or a stored procedure to run inside the database at a set time
- run a SQL function every few seconds from the database itself
- refresh a materialized view on a schedule in Postgres
- schedule recurring maintenance on our managed Postgres where we can't use the server's crontab
- see the history of scheduled database jobs, with which ones failed and why
- process the payroll procedure at noon on the last day of every month in Postgres
- keep scheduled database tasks running after a failover without a separate scheduler box
- schedule SQL jobs in several databases on the same Postgres server

## Features

- cron.schedule, cron.schedule_in_database, cron.unschedule and cron.alter_job functions
- standard cron syntax from Vixie cron, plus $ for the last day of the month
- interval schedules from 1 to 59 seconds
- parallel jobs, one instance of each job at a time (a late run is queued)
- run history and status in cron.job_run_details
- jobs run with the scheduling user's permissions; row-level security hides other users' jobs
- libpq connections or background workers to run jobs
- settings for time zone, maximum running jobs, logging and disabling all jobs without a restart
- starts automatically when a hot standby is promoted
- packages for PGDG yum and apt.postgresql.org; builds on Windows

## Limitations

- Doesn't run jobs on a hot standby: the scheduler starts only when the server is promoted[^3]
- Doesn't install in more than one database per cluster: jobs for other databases use cron.schedule_in_database[^3]
- Doesn't clean up its run history automatically: cron.job_run_details grows until you delete old rows[^3]

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by Citus Data

Warnings:

- GitHub activity not fetched yet

## Related

- Works with [PostgreSQL](https://talira.ai/catalog/postgresql-cm55wcnd.md)

## Sources

[^1]: https://formulae.brew.sh/api/formula.json (checked 21 Nov 2026)
[^2]: https://deb.debian.org/debian/dists/stable/main/source/Sources.xz (checked 21 Nov 2026)
[^3]: https://github.com/citusdata/pg_cron (checked 20 Nov 2026)
[^4]: https://github.com/citusdata/pg_cron/blob/main/LICENSE (checked 20 Nov 2026)
[^5]: https://formulae.brew.sh/api/formula/pg_cron.json (checked 20 Nov 2026)
