Cron schedules aren't correct

I have these 4 Cron schedules in my config file

CronProcess1 = "30 13 */15 * *" # every 15 days at 1:30pm
CronProcess1Reminder = "30 13 */3 * *" # every 3 days at 1:30pm

CronProcess2 = "30 13 */3 * *" # every 3 days at 1:30pm
CronProcess2Reminder = "30 13 */1 * *" # every day at 1:30pm

I initialized a new Cron job using

c := cron.New(cron.WithLogger(adapters.GetCronLoggerAdapter()), cron.WithLocation(time.UTC))

Looking at my logs, it looks like the different processes weren’t scheduled corrcetly

schedule [[now 2021-06-28 06:27:26.8877311 +0000 UTC entry 1 next 2021-07-01 13:30:00 +0000 UTC]] 
schedule [[now 2021-06-28 06:27:26.8877311 +0000 UTC entry 2 next 2021-06-28 13:30:00 +0000 UTC]]
schedule [[now 2021-06-28 06:27:26.8877311 +0000 UTC entry 3 next 2021-06-28 13:30:00 +0000 UTC]]
schedule [[now 2021-06-28 06:27:26.8877311 +0000 UTC entry 4 next 2021-06-28 13:30:00 +0000 UTC]]

entry 1 should be 2021-07-13 13:30:00. Other entries aren’t correct either
Any idea what could be causing this?

Library: github.com/robfig/cron/v3

What time zone are you in? Is 6:30 AM in your time zone the same as 01:30 PM in UTC?

1 Like

I think it might be an issue with my time zone settings. Looking at my laptop, it says I’m in (UTC +3:00)
But checking my time zone from google, it says Eastern Daylight Time (GMT-4)

Also reran the logs. Now is 2pm, but it says
[[now 2021-06-29 11:02:04.9369524 +0000 UTC entry 1 next 2021-07-01 12:30:00 +0000 UTC]]
for 30 12 */15 * *

So your systems timezone is misconfigured it seems.

If it does not match your geographical location, of course any calculation based on the timezone will be wrong.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.