Convert Spring cron to Kubernetes
Spring writes sec min hour dom mon dow; Kubernetes writes min hour dom mon dow. Paste an expression to convert it. Anything that does not map exactly is flagged with the reason and a workaround.
day of month: Kubernetes has no “last day of the month”. Months end on the 28th to the 31st, so no single day matches.
WorkaroundRun on days 28-31 and exit unless tomorrow is the 1st. Needs GNU date; in crontab, % is escaped as \%.
Not equivalent on its own: it needs a check inside the job.0 0 28-31 * * # job: [ "$(date -d tomorrow +%d)" = "01" ] || exit 0
Same schedule on other platforms
day of month: crontab has no “last day of the month”. Months end on the 28th to the 31st, so no single day matches.
WorkaroundRun on days 28-31 and exit unless tomorrow is the 1st. Needs GNU date; in crontab, % is escaped as \%.
Not equivalent on its own: it needs a check inside the job.0 0 28-31 * * [ "$(date -d tomorrow +\%d)" = "01" ] && /path/to/job
day of month: GitHub Actions has no “last day of the month”. Months end on the 28th to the 31st, so no single day matches.
WorkaroundRun on days 28-31 and exit unless tomorrow is the 1st. Needs GNU date; in crontab, % is escaped as \%.
Not equivalent on its own: it needs a check inside the job.0 0 28-31 * * # job: [ "$(date -d tomorrow +%d)" = "01" ] || exit 0
cron(0 0 L * ? *)0 0 0 L * ?Next 10 runs
computed in your browser- Calculating…
Spring vs Kubernetes
| Spring | Kubernetes | |
|---|---|---|
| Fields | sec min hour dom mon dow | min hour dom mon dow |
| Sunday | 0 or 7 | 0 (7 is an error) |
| Day and weekday both set | both must match | either matches; only * or ? leaves a field open |
| Special characters | L W # LW L-n | none |
| Shortcuts | @yearly @monthly @weekly @daily @hourly | @yearly @monthly @weekly @daily @hourly |
| Time zone | zone=, else the JVM zone | spec.timeZone, else the controller’s zone |
| Shortest interval | 1 second | 1 minute |
Common schedules, converted
| Spring | Kubernetes | |
|---|---|---|
| Every 5 minutes | 0 */5 * * * * | */5 * * * * |
| Every hour | 0 0 * * * * | 0 * * * * |
| Every minute | 0 * * * * * | * * * * * |
| Every 10 minutes | 0 */10 * * * * | */10 * * * * |
| Every 15 minutes | 0 */15 * * * * | */15 * * * * |
| Every 30 minutes | 0 */30 * * * * | */30 * * * * |
| Daily at midnight | 0 0 0 * * * | 0 0 * * * |
| Daily at 9 am | 0 0 9 * * * | 0 9 * * * |
| Weekdays at 9 am | 0 0 9 * * 1-5 | 0 9 * * 1-5 |
| Every Monday | 0 0 0 * * 1 | 0 0 * * 1 |
| First day of the month | 0 0 0 1 * * | 0 0 1 * * |
| Every 6 hours | 0 0 */6 * * * | 0 */6 * * * |
| Every Sunday at midnight | 0 0 0 * * 0 | 0 0 * * 0 |
| Every 2 hours | 0 0 */2 * * * | 0 */2 * * * |
| Every 12 hours | 0 0 */12 * * * | 0 */12 * * * |
| Daily at noon | 0 0 12 * * * | 0 12 * * * |
| Every Friday | 0 0 0 * * 5 | 0 0 * * 5 |
| Last day of the month | 0 0 0 L * * | Can’t convert |
| Every quarter | 0 0 0 1 */3 * | 0 0 1 */3 * |
| Every 2 minutes | 0 */2 * * * * | */2 * * * * |
| Every 3 hours | 0 0 */3 * * * | 0 */3 * * * |
| Daily at 6 am | 0 0 6 * * * | 0 6 * * * |
| Daily at 6 pm | 0 0 18 * * * | 0 18 * * * |
| Twice a day | 0 0 */12 * * * | 0 */12 * * * |
| Weekdays at 6 pm | 0 0 18 * * 1-5 | 0 18 * * 1-5 |
| Weekends at 10 am | 0 0 10 * * 0,6 | 0 10 * * 0,6 |
| 15th of the month | 0 0 0 15 * * | 0 0 15 * * |
| First Monday of the month | 0 0 9 * * MON#1 | Can’t convert |
| Last Friday of the month | 0 0 17 * * FRIL | Can’t convert |
| Once a year | 0 0 0 1 1 * | 0 0 1 1 * |
| Every 30 seconds | */30 * * * * * | Can’t convert |
| Every 3 minutes | 0 */3 * * * * | */3 * * * * |
| Every 20 minutes | 0 */20 * * * * | */20 * * * * |
| Every 4 hours | 0 0 */4 * * * | 0 */4 * * * |
| Every 8 hours | 0 0 */8 * * * | 0 */8 * * * |
| Daily at 1 am | 0 0 1 * * * | 0 1 * * * |
| Daily at 2 am | 0 0 2 * * * | 0 2 * * * |
| Daily at 3 am | 0 0 3 * * * | 0 3 * * * |
| Daily at 8 am | 0 0 8 * * * | 0 8 * * * |
| Every weekday | 0 0 0 * * 1-5 | 0 0 * * 1-5 |
| Every weekend day | 0 0 0 * * 0,6 | 0 0 * * 0,6 |
| Every Tuesday | 0 0 0 * * 2 | 0 0 * * 2 |
| Every Wednesday | 0 0 0 * * 3 | 0 0 * * 3 |
| Every Thursday | 0 0 0 * * 4 | 0 0 * * 4 |
| Every Saturday | 0 0 0 * * 6 | 0 0 * * 6 |
| Every 6 months | 0 0 0 1 */6 * | 0 0 1 */6 * |
| Every 10 seconds | */10 * * * * * | Can’t convert |
| Every 5 seconds | */5 * * * * * | Can’t convert |
FAQ
Can every Spring expression be converted to Kubernetes?
Not all. Of the 48 common schedules on this page, 42 convert exactly. The rest need a workaround, which the converter shows.
How is Sunday written in Spring and Kubernetes?
Spring: 0 or 7. Kubernetes: 0 (7 is an error).
Does the time zone carry over?
The expression has no time zone. Spring: zone=, else the JVM zone. Kubernetes: spec.timeZone, else the controller’s zone.