简体   繁体   中英

Spring Scheduled cron job

I need two cron jobs and I am really not sure if I am doing right. One con job should run every 01.01.xxx at 01:00 o'clock and the other should run every night at 01:00.

@Scheduled(cron = "0 0 01 01 01 ?") // every year 01.01 at 01:00 o'clock
@Scheduled(cron = "0 0 01 * * *") // very day at 01:00 o'clock

Are these the correct expression?

Yes.

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.

Every day syntax is "sec min hour * * *"

Once a year syntax is "sec min hour day_of_month month ?"

(Normally "01" is written as "1")

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html

Spring cron expression for every day 1:01:am

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM