Spring Boot Job Scheduler fixedDelay and cron

Viewed 1135

I'm running a spring boot scheduled process that takes 5-10 seconds to complete. After it completes, 60 seconds elapse before the process begins again (Note that I'm not using fixedRate):

@Scheduled(fixedDelay=60_000)

N ow, I want to limit it to run every minute Mon-Fri 9am to 5pm. I can accomplish this with

@Scheduled(cron="0 * 9-16 ? * MON-FRI")

Problem here is that this acts similar to fixedRate - the process triggers EVERY 60 seconds regardless of the amount of time it took to complete the previous run...

Any way to to combine the two techniques?

1 Answers

Try below:

@Schedules({ 
  @Scheduled(fixedRate = 1000), 
  @Scheduled(cron = "* * * * * *")
})
Related