Cron every 5 hours: 0 */5 * * * and the four hour gap
0 */5 * * * runs at 00:00, 05:00, 10:00, 15:00 and 20:00, five times a day. The gap from 20:00 to the next midnight is four hours, not five.
At a glance
- Expression
- 0 */5 * * *
- Fires
- 5 times a day, 35 times a week.
- Restricted fields
- Minute pinned to 0, hour stepped by 5. Date fields open.
- Equivalent macro
- None.
- Hours matched
- 0, 5, 10, 15, 20.
- Gap pattern
- Five hours four times, then a four hour gap across midnight.
In detail
Five does not divide 24, so the step runs out before the field does. The walk starts at hour 0 and adds 5 until it passes 23, giving 0, 5, 10, 15 and 20. The next value would be 25, which does not exist, so the schedule restarts at hour 0 of the following day and the final gap is four hours rather than five.
That irregular gap is the whole story of this schedule, and it is the same story for every hour step that is not a divisor of 24: 7, 9, 10, 11 and everything above 12 except nothing at all. If uniform spacing matters, pick from 1, 2, 3, 4, 6, 8 or 12, which are the divisors, and the midnight boundary disappears as a concern.
If five hours really is the requirement, the interval and the day only come back into phase after five days, which is 24 runs across 120 hours. Expressing that in cron would need the day of month field, and the month boundary would break the phase again, so the honest answer is that cron is the wrong tool for a fixed interval that does not divide a day.
Where this schedule is fine is the common case where somebody said five hours but meant roughly five hours. Five runs a day spread across the clock is a perfectly reasonable cadence, and the four hour gap between the last run of one day and the first of the next changes nothing for a job that just needs doing regularly.
Examples
0 */5 * * *00:00, 05:00, 10:00, 15:00, 20:00. Then midnight again, four hours later.
0 */4 * * *Six runs a day, exactly four hours apart, no boundary gap.
0 */6 * * *Four runs a day, exactly six hours apart.
Things that catch people out
- A job that compares its run time to the previous run and alerts on a gap over four and a half hours will fire a false alarm every single night.
- Adding a start offset does not fix the gap. 0 2-23/5 gives 2, 7, 12, 17, 22 and still has an uneven boundary, because the problem is the divisor, not the phase.
- The same trap exists in the minute field for steps that do not divide 60, which is why */45 and */25 behave the way they do.
Try it: Cron Expression Parser
Paste any five or six field expression to get a plain English description, a per field breakdown and the next run times in your local time.
Cron Expression Parser
LOCAL · Browser-OnlyParse cron expressions and see the next scheduled run times
Supports 5-field (minute hour day month weekday), 6-field (with seconds), named values (JAN, MON), and @macros (@daily, @hourly, ...)
Use the dropdowns below to build your cron expression visually, or type a custom value in each field.
Human-Readable Description
Every 5 minutes
Field Breakdown
| Field | Allowed | Value | Meaning |
|---|---|---|---|
| Minute | 0-59 | */5 | every 5 minute(s) |
| Hour | 0-23 | * | every hour |
| Day of Month | 1-31 | * | every day of month |
| Month | 1-12 | * | every month |
| Day of Week | 0-7 | * | every day of week |
Related cron expressions
All cron expressions →Cron every 4 hours: 0 */4 * * *
0 */4 * * * fires six times a day at 00:00, 04:00, 08:00, 12:00, 16:00 and 20:00. Even spacing, and how to move the set off midnight.
Cron every 6 hours: 0 */6 * * *
0 */6 * * * fires four times a day at 00:00, 06:00, 12:00 and 18:00. Even spacing, quarter day alignment, and how to shift the whole set.
Cron every 45 minutes: why */45 * * * * does not do it
*/45 * * * * fires at minute 0 and minute 45 only, so the gaps alternate 45 and 15 minutes. Here is the four line crontab that really runs every 45 minutes.
The cron hour field: 0 to 23 on a 24 hour clock
The hour field runs 0 to 23 on a 24 hour clock. Midnight is 0, noon is 12, and 24 is out of range. There is no AM or PM notation.
Cron every 8 hours: 0 */8 * * *
0 */8 * * * fires three times a day at 00:00, 08:00 and 16:00. Shift aligned, evenly spaced, and easy to move with a start at step form.
Cron every 12 hours: 0 */12 * * *
0 */12 * * * fires twice a day, at 00:00 and 12:00. Identical to 0 0,12 * * *, and different from an arbitrary twice daily schedule.
Tools for this
- Cron Expression Parser Free online cron expression parser - parse cron expressions and see the next scheduled run times
- Crontab Generator Free online crontab generator - build cron expressions visually with an intuitive interface