citusdata / pg_cron

Run periodic jobs in PostgreSQL
PostgreSQL License
2.9k stars 195 forks source link

cron scheduling #357

Open ramkly opened 2 months ago

ramkly commented 2 months 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 3 weeks 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