crontool
Paste a schedule, read it in English, see the next runs.

Spring @Scheduled Cron Expression

Spring's @Scheduled cron has SIX fields — it adds a leading seconds field before the usual five. So second minute hour day-of-month month day-of-week. The example below runs at 9 AM every weekday.

The annotation

@Scheduled(cron = "0 0 9 * * MON-FRI")
public void report() { ... }

Fields: second minute hour day-of-month month day-of-week. This fires at 09:00:00 Monday through Friday.

The extra seconds field

Unlike Unix cron, Spring requires the leading seconds field. */30 * * * * * runs every 30 seconds. Forgetting the sixth field is the most common error.

Day-of-week

Use names (MON–SUN) or numbers 0–7. Use ? to leave day-of-month or day-of-week unspecified when you set the other, e.g. 0 0 9 1 * ? for the 1st of each month.

Set the timezone

By default it uses the server zone. Pin it: @Scheduled(cron = "0 0 9 * * MON-FRI", zone = "America/New_York"). Enable scheduling with @EnableScheduling on a config class.

FAQ

How many fields does a Spring cron have?

Six. Spring adds a leading seconds field: second minute hour day-of-month month day-of-week. 0 0 9 * * MON-FRI runs at 9 AM on weekdays.

How do I set a timezone for @Scheduled?

Pass the zone attribute: @Scheduled(cron = "...", zone = "America/New_York"). Without it, Spring uses the server's default timezone.

Why does my Spring cron throw an error?

Usually a missing seconds field — Spring needs 6 fields, not 5. Add a leading 0 for on-the-minute schedules, and use ? for the unused day field.