cron icon indicating copy to clipboard operation
cron copied to clipboard

reset next job execution if the system time has been moved backwards

Open drakkan opened this issue 2 years ago • 0 comments

Suppose you have a job scheduled every minute.

The current time is 15:00:00 and for reasons outside our control it is set to 17:00:00, the job runs as expected and "Next" will be set to 17:01:00. If the system clock returns to the correct time and so now is, for example, 15:01:00, when we calculate the duration of the timer here

https://github.com/robfig/cron/blob/bc59245fe10efaed9d51b56900192527ed733435/cron.go#L259

we will have something like 2 hours and then no job runs for 2 hours.

This patch fixes the issue. Thank you

drakkan avatar Feb 20 '23 16:02 drakkan