6

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
  • 8,084
  • 8
  • 48
  • 62
TechLife
  • 173
  • 2
  • 4
  • 16

3 Answers3

5

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
  • 6,538
  • 1
  • 22
  • 31
  • 1
    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
0

0 0 0 */1 * *

I am using this command to run once everyday. You can also use

0 0 0/24 * * *

to run once every 24 hours

Neha Agarwal
  • 314
  • 2
  • 10