quma
quma

Reputation: 5753

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?

Upvotes: 1

Views: 5267

Answers (1)

Ian Mc
Ian Mc

Reputation: 5829

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

Upvotes: 1

Related Questions