Cron explainer › Examples

Cron expression for last day of every month

At 00:00 on the last day of the month

SyntaxExpression
Unix crontab Not supported: Unix crontab does not support special characters like L, W or #.
Spring @Scheduled 0 0 0 L * *
Quartz 0 0 0 L * ?

Open and edit in the explainer →

Tip crontab does not support L. Run on days 28-31 and check inside the script with [ "$(date -d tomorrow +%d)" = "01" ].

Next run times (UTC)

  1. Calculating…

Configuration examples

Spring

@Scheduled(cron = "0 0 0 L * *", zone = "UTC")
public void runJob() {
    // ...
}

Requires @EnableScheduling. Without zone, the server time zone is used.

Quartz

Trigger trigger = TriggerBuilder.newTrigger()
    .withIdentity("myTrigger")
    .withSchedule(CronScheduleBuilder.cronSchedule("0 0 0 L * ?")
        .inTimeZone(TimeZone.getTimeZone("UTC")))
    .build();

Quartz always needs "?" in either day-of-month or day-of-week.

More cron examples

Every minuteEvery 5 minutesEvery 10 minutesEvery 15 minutesEvery 30 minutesEvery hour (on the hour)Every 2 hoursEvery 6 hoursEvery day at midnightEvery day at 9 AMEvery day at 6 PMTwice a day (9:00 and 18:00)Weekdays at 9 AMEvery 10 minutes during business hoursWeekends at 10 AMEvery Monday at 9 AMEvery Sunday at midnightFirst day of every month15th of every monthLast weekday of every monthSecond Monday of every monthLast Friday of every monthEvery quarter (Jan, Apr, Jul, Oct 1st)Every year on January 1stEvery 10 secondsEvery 30 seconds