'How to run spring scheduled jobs only in specific year?
@Scheduled(cron = "0 0 0 * * *")
This runs a spring scheduled job at midnight. How could I add the year excplicit where this job should run? (I just want to disable a job in test environment for this year, so I want to set 2016).
Solution 1:[1]
Spring scheduling cron only admit six parameters: second, minute, hour, day, month, weekday. You can see documentation here: https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html
Solution 2:[2]
you can mention it by this way
@Scheduled(cron = "0 15 10 * * ? 2016")
Fire at 10:15 AM every day during the year 2016
for complete reference schedule reference
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rBay |
| Solution 2 | muneebShabbir |
