cron
cron copied to clipboard
Job scheduled for between 5 years and 100000 hours will not be run
According to this line, no next time will be returned if the next action is outside 5 years: https://github.com/robfig/cron/blob/e843a09e5b2db454d77aad25b1660173445fb2fc/spec.go#L87
In the main cron loop the time, if no next time is found, it will wait 100000 hours:
https://github.com/robfig/cron/blob/e843a09e5b2db454d77aad25b1660173445fb2fc/cron.go#L252
This means in the time window between 5 years and 100000 hours you can skip a job by accident.
I may be mistaken, but i thought it was a fun bug.
Yes, because of the way it calculates the next job's trigger time (iteration), it has to pick some threshold beyond which it gives up. 5 years is an amount of time beyond which it seemed implausible to have any use case for scheduling a job farther out. 100k hours is more like 11 years, which is outside that realm. I'd be happy to review a fix that removes that limitation, but it seems low priority and wouldn't be worth a great complication IMO.
@robfig I guess the fix is to just bring those two windows into sync.
dude if you're running stuff so insanely long you need to run
//pull this out of a database or whatever
if 1793907730 < time.Now().Unix() {
//do your tasks
}
because this will traverse reboots, server changes, computer changes, database updates, program restarts, etc... and yours will reset it's timer everytime anything happens.
@G2G2G2G obviously - its just a low impact bug. Not every server is rebooted every 5 years so I just thought it was funny if anyone actually has such a crazy cron job.
That's a wait timer not a cron job..
Please reread and understand the original issue before commenting again I am unsubscribing from this issue as I have no intention of fixing it - just reporting it.
https://crontab.guru/ demonstrate a cron job that runs in 5 years