Search code examples
springmethodscronscheduled-tasksimplementation

Translating and understanding the @Scheduled cron message


I have this code.

This cron message means "do this method every Sunday in 01.00 a.m." or I make a mistake translating this?

@Scheduled(cron = "0 1 0 * * ?")
private void notificationsScheduler() {
    //implementation
}

Solution

  • Your expression

    "0 1 0 * * ?" 
    

    means: At 00:01:00am every day

    As per your requirement : At 01:00:00am, on every Sunday, every month

    Use:

    0 0 1 ? * SUN *
    

    Follow this https://www.freeformatter.com/cron-expression-generator-quartz.html for more detail.