I have the following code in spring boot, its working fine and job running for every 5 mins.
I want it run between 9:30 AM to 5:30 PM for every 5 minutes.
How to add the the specific time period for below cron expression.
@Scheduled(cron = “0 */5 * ? * *”)
public void runEvey5Minutes() {
System.out.println(“Current time is :: “ + LocalDate.now());
}
Maybe you can do it in one expression, but I doubt it. The hard part is that is starts at 8:30 AM and end at 5:30 PM. So the interval is not symetric, I thinks this make it impossible to parse into one expression.
My idea would be to split it in 3 expression:
Then you would need 3 methods with the
@Scheduledannotation, they should al run the same job of course.If you want to test if they work, check out this code
Hope this helps