Reputation: 1010
is there any expert having the issue using springboot scheduler
trying to set it to run between 2pm til 10pm on weekday every 15mins/per hour, but it seem like trigger by minute, is that because my cron is wrong or i shld do smthg to control it ?
running in linux server via springboot-web-started
@Scheduled(cron = "0 15 14-22 * * MON-FRI")
private void fireDownload() {
log.info("fireDownload");
this.jmsXXXX.run(Constants.XXXX);
}
version
spring-boot 2.4.2 java 11
Upvotes: 0
Views: 493
Reputation: 10679
Please try this
@Scheduled(cron = "0 */15 14-22 * * MON-FRI")
You say in a comment that this is not working, so let's test this with a simple proof-of-concept that fires every 5 minute
@Scheduled(cron = "0 */5 8-22 * * MON-FRI")
private void cronPOC() {
log.info("cronPOC triggered by cron");
}
Screen-shot below shows that the POC is indeed working.
While we're at testing, let's put @GerbenJongerius suggestion from comment above to the test as well (with some tiny changes in order to speed things up).
@Scheduled(cron = "0 0/5 8-22 ? * MON-FRI")
private void cronPOC() {
log.info("cronPOC triggered by cron v2");
}
Some Spring cron examples with explanations here: https://stackoverflow.com/a/26147143/14072498
Upvotes: 2