Skip to content
cron.surf

Run a Spring @Scheduled task every weekday at midnight

The Spring expression for “Every weekday” is 0 0 0 * * 1-5. Below: config you can paste, the next run times, and what to watch out for. Spring’s @Scheduled(cron) takes six fields, seconds first, and needs every set day field to match.

0 0 0 * * 1-5Open in tool

“At 00:00, Monday through Friday”

@Scheduled method

@Scheduled
@Scheduled(cron = "0 0 0 * * 1-5", zone = "UTC")
public void everyWeekday() {
    // job
}

Spring gotchas

Seconds come firstSpring expressions have six fields: second, minute, hour, day of month, month, day of week. A five-field crontab line is rejected.
Both day fields must match0 0 9 1-7 * MON is the first Monday of the month. In crontab the same fields mean days 1-7 or any Monday.
Sunday is 0 or 7Unlike Quartz, where Sunday is 1. Names (MON-SUN) are safest when you move expressions between the two.
Scheduling must be switched onAdd @EnableScheduling to a configuration class or @Scheduled methods never run. By default all tasks share one thread.

FAQ

What is the Spring cron expression for “Every weekday”?

0 0 0 * * 1-5. It reads: At 00:00, Monday through Friday

Which time zone does a Spring schedule use?

In the JVM’s default time zone. Set zone = "Europe/Berlin" (any IANA name) on @Scheduled to pin it.

Can Spring cron run every 30 seconds?

Yes. Spring has a seconds field: */30 * * * * *.

Does Spring support L and #?

Yes, since Spring 5.3: L, LW, L-n and nW in day of month, and dL or d#n in day of week.