Timestamps and scheduling guides

Overnight Cron windows: split ranges across midnight

Describe an overnight schedule with valid hour ranges and define which date owns each execution.

Nav Tools ·

Do not use a descending hour range

A conventional Cron range runs from a lower value to a higher value. 22-2 is not a portable way to wrap across midnight.

List the two ranges explicitly for a daily overnight window, then preview from just before its start.

0 22-23,0-2 * * *
Daily runs: 22:00, 23:00, 00:00, 01:00, 02:00

Define whether the endpoint is included

This fixture includes 02:00. If the window ends immediately before 02:00, the final included hour is 01.

For quarter-hour runs, inspect the last minute as well: 02:45 is not within a window ending at 02:00.

Weekdays belong to actual execution dates

Adding Monday-Friday to the whole expression restricts each execution's local date. It does not mean Monday-Friday shifts that finish the next morning.

A Friday shift ending Saturday morning needs a separate after-midnight schedule or an application shift rule.

Evening:       0 22-23 * * 1-5
Following AM: 0 0-2   * * 2-6

Assign an explicit business date

A 00:30 event may belong to the previous day's shift even though its calendar date is today. Store the business date separately from its timestamp.

Preview in the intended timezone and test the week boundary. A Cron expression chooses instants; it does not assign accounting periods.

References

← Timestamps and scheduling guides