4

I want to schedule a method to run every 24 hours and with the settings I have it is executing every 24 minutes.

I have referred below URL's which has different suggestions

Link 1 suggests <second> <minute> <hour> <day-of-month> <month> <day-of-week> <year> <command>

Link 2 suggests minute hour day(month) month day(week)

Below are the cron settings put in the application.yml of my Spring Boot application.

cron: job: expression: 0 0 23 * * ?

Could someone help on what are the correct source of information and what can be the settings with the requirements at hand.

Vadim Kotov
  • 7,766
  • 8
  • 46
  • 61
TechLife
  • 143
  • 2
  • 3
  • 14

2 Answers2

4

0 0 * * *

This will run job at 12:00 am every day

2

If you run the scheduled job in spring the record must be as mentioned in first link:

0 0 23 * *

This will run the job at 23:00:00 every day

Romeo Ninov
  • 5,508
  • 1
  • 20
  • 29
  • i think this is not correct, your example will run the job each 23th day in month. The Signature is "m h dom mon dow". In order to run a Job at 23th hour, it would be "0 23 * * * /foo/bar/job" – Henry Jan 13 '21 at 10:31
  • @Henry, in Spring framework the first element is seconds: https://stackoverflow.com/a/26147143/2908599 Here is a Spring documentation: https://docs.spring.io/spring-framework/docs/3.0.x/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html – Romeo Ninov Jan 13 '21 at 12:34