Skip to content
SpringCronTools

converter · 01

Unix Cron to Spring Converter

Unix cron uses five fields. Spring uses six, with seconds first. This converter adds the seconds field and flags anything that changes meaning.

minute · hour · day-of-month · month · day-of-week

This looks like a Unix cron expression.

spring cron

0 0 9 ? * 1-5

before you use this

  • Seconds were added as "0", so the job now runs at second 0 of each matching minute instead of not being expressible in Unix cron.

fieldsUnix versus Spring

unix · 5 fields

minute hour day-of-month month day-of-week

spring · 6 fields

second minute hour day-of-month month day-of-week

Conversion is only lossless when the seconds field is 0 and the schedule does not depend on Spring-only constructs. Where it is not, the tool says so instead of pretending the result is equivalent.

nextRelated

Questions

How do I convert a Unix cron expression to Spring?

Add a seconds field of 0 in front and, if both day fields are restricted, replace one of them with ?. For example "0 9 * * 1-5" becomes "0 0 9 ? * 1-5".

Is every Unix cron expression convertible?

No. Unix cron has no L, W or # syntax, and it has no seconds field, so a Spring expression that relies on those constructs cannot be converted back without changing the schedule.

Why does my converted expression use ? instead of *?

In Spring, ? and * both mean "every value" in a day field, but ? makes it explicit that the other day field is the one doing the work. Spring requires both restricted day fields to match, so leaving the unused field as * would still work but reads worse.