Now I have the following declaration:
@Scheduled(cron = "0 0 12 ? * MON#1")
protected synchronized void execute() {...}
and it doesn't work:
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.9.RELEASE.jar:1.5.9.RELEASE]
Caused by: java.lang.IllegalStateException: Encountered invalid @Scheduled method 'execute': For input string: "2#1"
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.processScheduled(ScheduledAnnotationBeanPostProcessor.java:461) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.postProcessAfterInitialization(ScheduledAnnotationBeanPostProcessor.java:331) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 19 common frames omitted
Please, help to make it working
the expression is wrong use @Scheduled(cron = "0 0 0 ? * 2#1 *")
Refer the below for more info on this
https://stackoverflow.com/a/26147143/3724760
The pattern is a list of six single space-separated fields: representing
second,
minute,
hour,
day,
month,
weekday.
Month and weekday names can be given as the first three letters of the English names.
So a Monday in the first 7 days of the month should generate what you are after.
"0 0 12 1-7 * MON"
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html
This may work for you
For description check here
https://cronexpressiondescriptor.azurewebsites.net