Issues running cron jobs at specific times in PostgreSQL using pg_cron #31024
Unanswered
ricardosikic
asked this question in
Questions
Replies: 1 comment 2 replies
-
I’ve not had any issues with specific times. Try the new Cron UI and see what time pattern that gets. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I configured a cron job in PostgreSQL with pg_cron as follows:
SELECT cron.schedule('update-events', '0 0 * * *', 'CALL update_event_active_status()');
I expected this job to run every day at midnight. However, when I checked after midnight, I noticed it hadn't executed.
To test, I created a cron job with the same function but scheduled it as follows:
SELECT cron.schedule('update-events', '* * * * *', 'CALL update_event_active_status()');
Surprisingly, this job ran correctly every minute (and seemingly every second, as per my monitoring). Still, I cannot get jobs scheduled for specific times (like 0 0 or 30 0) to work properly.
The function used by the cron job is as follows:
Additionally, I configured the PostgreSQL timezone to America/Santiago with:
SET timezone = 'America/Santiago';
I verified the timezone settings with:
Both confirmed the server time is correct.
Could there be an issue with pg_cron or the way it handles time-based schedules in PostgreSQL? Am I missing a step to ensure jobs scheduled for specific times work properly?
Any guidance or solutions would be greatly appreciated. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions