pg_cron icon indicating copy to clipboard operation
pg_cron copied to clipboard

cron scheduling

Open ramkly opened this issue 1 year ago • 2 comments

Hi, I have servers in different time zones, and I know that pg_cron schedules jobs by default in UTC. Is there any way to schedule jobs based on the server's local time zone instead of UTC?

ramkly avatar Sep 23 '24 11:09 ramkly

You can view the cron settings by running:

SELECT * FROM pg_settings where name ilike '%cron%';

pg_cron can only run within one database in your cluster. You can change the default by running:

ALTER SYSTEM SET cron.timezone = '<timezone>';

Because it's a postmaster level setting, you'll have restart the cluster (pg_ctl). You can view valid timezones in the postgres docs

TheOtherBrian1 avatar Nov 01 '24 05:11 TheOtherBrian1

May be worth adding that pg_cron utilizes the standard postgres time zones in that link to the README. If that is in fact the exhaustive list, things like 'America/New_York' won't work. The current documentation is unclear

walker-philips avatar May 08 '25 00:05 walker-philips