Search code examples
springcronexpression

Spring cron job expression help me to understand


Spring java cron job.

I have following spring cron job expression but i don't understand what does that mean

please take a look */15 * 0,2-23 * * * i understand only first part which is every after 15 seconds ? what else ?


Solution

  • This link has some good descriptions of the fields and what they mean.

    1. The first is for seconds, and like you said, you understand that it means every 15 seconds.
    2. The second field is for minutes, and it is every minute of the hour.
    3. The third field is for hours, and it is suggesting the 0th hour (midnight) and the hours 2-23. This is basically every hour but 1 am.
    4. The rest of the fields don't restrict anything, so it would be everyday...for the rest of time.

    So what we are seeing here, is an expression that will schedule some event for every fifteen seconds between the hours of 2 am and 1 am the following day (23 straight hours). From 1 am until 2 am, this event will not occur. And this will happen everyday indefinitely.