Home โบ Cron errors โบ Spring
Spring error: cron expression must consist of 6 fields
java.lang.IllegalStateException: Encountered invalid @Scheduled method: Cron expression must consist of 6 fields (found 5) in "*/5 * * * *"Why this happens
Spring's @Scheduled uses six fields with seconds first. A five-field crontab line has no seconds.
Wrong and right
*/5 * * * *Our parser says: Spring @Scheduled (6-field) needs 6 fields, but you gave 5
0 */5 * * * *Every 5 minutes. First runs after 1 Jan 2027 (UTC): Fri 01 Jan, 00:05, Fri 01 Jan, 00:10, Fri 01 Jan, 00:15, Fri 01 Jan, 00:20, Fri 01 Jan, 00:25
How to fix it
- Add 0 in front for the seconds field.
- Or switch to fixedRate / fixedDelay for simple intervals.
- Convert existing crontab lines with a converter instead of editing by hand.
The Spring format at a glance
Fields in order: second (0-59), minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-7, 0 and 7 = Sunday).
Spring evaluates in the server time zone by default. Add zone = "UTC" (or any ZoneId) to @Scheduled to make it explicit.
The fixed schedule in other systems
If you are moving this schedule to another scheduler, these are the equivalents of 0 */5 * * * *:
| System | Expression |
|---|---|
| Quartz | 0 */5 * * * ? |
| Crontab | */5 * * * * |
| Kubernetes | */5 * * * * |
| AWS EventBridge | */5 * * * ? * |
| Jenkins | */5 * * * * |
| GitHub Actions | */5 * * * * |
| node-cron | */5 * * * * |
| Apache Airflow | */5 * * * * |
| Azure Functions | 0 */5 * * * * |
| Google Cloud Scheduler | */5 * * * * |
Try it yourself
The tester below starts with the fixed expression. Change it and watch the schedule update.
Your week at a glance
Upcoming runs
| # | Local | UTC | From now |
|---|
Copy-ready code
Frequently asked questions
What does the first field mean in Spring cron?
Seconds. 0 means at the start of the minute.
More Spring fixes
See the full Spring cron builder or convert between formats.