W3docs

Spring cron expression for every day 1:01:am

To create a cron expression that triggers an event every day at 1:01 AM, you can use the following cron expression:

To create a cron expression that triggers an event every day at 1:01 AM, you can use the following cron expression:

0 1 1 * * *

Spring's @Scheduled annotation uses a 6-field cron expression (second, minute, hour, day of month, month, day of week), unlike the standard 5-field format:

  1. second (0)
  2. minute (1)
  3. hour (1)
  4. day of month (*)
  5. month (*)
  6. day of week (*)

The * wildcard indicates that the event should be triggered for all values of the field. In this case, the event will be triggered every day of the month, every month, and every day of the week.

You can use this cron expression in a Spring application by annotating a method with @Scheduled and setting the cron attribute to the expression:


@Scheduled(cron = "0 1 1 * * *")
public void myTask() {
    // task logic here
}

I hope this helps! Let me know if you have any questions.