citusdata / pg_cron

Run periodic jobs in PostgreSQL
PostgreSQL License
2.88k stars 193 forks source link

cron scheduling #357

Open ramkly opened 1 month ago

ramkly commented 1 month ago

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?

TheOtherBrian1 commented 1 week ago

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