Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Scheduled execution (cron) should never execute ahead of exact scheduled time [SPR-12099] #16715
Scheduled executions (using cron) occasionally execute ahead of the scheduled execution time. The is particularly a problem when the code depends some aspect of the date/time and the value is incorrect.
See the simplified example below along with log4j output. I would have expected the execution to be no earlier that 2014-08-19 00:00:00.
Juergen Hoeller commented
It seems that we're correctly calculating the next execution time there... and that the target executor (e.g. the JDK's ScheduledThreadPoolExecutor) isn't 100% accurate in its actual execution points.
If you're relying on the execution being on the new day, the best I can recommend for the time being is to add a second or two to your cron trigger...