Guide

How to Validate a Cron Expression and Find the Next Runs

Enter a five-field cron expression to validate it and calculate its next five run times from the current UTC time. Successful results are returned as five UTC ISO-formatted date-time strings; valid schedules can still fail if no match occurs within ten years.

Tool Cron Expression Parser

What a five-field cron parser does

A cron expression describes when a recurring task should run. This parser checks a five-field expression and, when the schedule can be calculated, returns the next five run times from the current UTC time. It is useful when you need to review a schedule before adding it to a task runner or when you want to confirm the calendar dates produced by a recurring rule.

The fields follow the UNIX-style order minute, hour, day of month, month, day of week. The tool also accepts surrounding whitespace and repeated spaces because they are normalized before validation. If you leave the expression blank, it uses */5 * * * *, which represents a five-minute interval.

How to validate an expression and find upcoming runs

  1. Enter the cron expression in the input. Use five whitespace-separated fields in this order: minute, hour, day of month, month, and day of week. For example, 0 0 1 * * schedules a run at midnight on the first day of a month.

  2. Check the field count before submitting. The expression must contain exactly five fields. A six-field expression or an expression with fewer fields fails before the schedule is calculated.

  3. Submit the expression for validation and calculation. The search starts from the current UTC time, with fractional seconds removed. The parser then looks for upcoming calendar occurrences.

  4. Review the returned schedule. A successful calculation contains the next five occurrences as ISO-formatted date-time strings, with UTC identified as the time zone.

  5. If the expression fails, review both its syntax and its expected schedule. A valid-looking expression can still fail when no upcoming match is found within the ten-year search limit. Also check the day rules: when both day-of-month and day-of-week restrictions are present, a match for either restriction is sufficient.

How to read the result

A successful result gives you five future calendar occurrences rather than only a pass/fail syntax check. Read the timestamps as UTC, then convert them to your application’s time zone if needed. Because the calculation begins at the current UTC time, the returned dates depend on when you submit the expression.

The result reflects the parser’s five-field model. It should not be treated as confirmation that a six-field expression, a different cron dialect, or every cron implementation will behave the same way. A failure can indicate malformed syntax, an invalid date, value, or key, or the absence of a match within ten years. The parser returns failure for these handled problems instead of successful schedule data.

Worked example

You need to check a monthly task scheduled for midnight on the first day of a month.

Enter 0 0 1 * * and submit it for validation and schedule calculation.

A successful result contains five ISO-formatted date-time strings identified as UTC. For this schedule, the occurrences are at midnight on the first day of successive months when those dates fall after the calculation start.

Limitations

  • The documented behavior covers five-field expressions, and a schedule can fail when no match appears within the ten-year search limit.
  • When both day-of-month and day-of-week restrictions are present, the parser uses OR matching, which may differ from another cron implementation’s interpretation.

Common errors

  • Using six fields or putting the values in the wrong order causes failure. Remove the extra field and check that the expression reads minute, hour, day of month, month, then day of week.

FAQ

How many fields can a cron expression contain?

The parser expects exactly five whitespace-separated fields: minute, hour, day of month, month, and day of week. Other field counts return failure before schedule calculation.

Are the next run times calculated in UTC?

The calculation starts from the current UTC time with fractional seconds removed, so the returned dates depend on when you submit the expression.

Why can a valid cron expression fail?

A syntactically valid expression can still return failure when no upcoming match is found within the ten-year search limit. Check the schedule’s possible future matches as well as its syntax.

Tool

Cron Expression Parser