Using pg_cron in Managed Service for PostgreSQL
Written by
Updated at December 25, 2025
The pg_cron
Install the pg_cron extension in your PostgreSQL cluster
To install pg_cron in a PostgreSQL cluster:
-
Load the shared library
pg_croninto your cluster. -
Enable the
pg_cronextension in one of your databases. You cannot enable this extension for two databases.Warning
Installing
pg_cronwill trigger a rolling restart of PostgreSQL on all cluster hosts. -
Assign the
mdb_adminrole to the user who will be managing the jobs.
The database will now contain the cron schema with tables and functions required for the extension:
-
Tables:
cron.job: Contains scheduled jobs. You can runSELECTqueries on this table.cron.job_run_details: Contains extension run history. You can runSELECT,UPDATE, andDELETEqueries on this table.
-
Functions:
schedule: Creates a job in the database with the installedpg_cronextension.schedule_in_database: Creates a job in a different database.unschedule: Deletes a job.alter_job: Alters a job.
To learn more about the pg_cron extension, see its official documentation