Cron expression for every 4 hours

Runs the job every fourth hour, six times a day.

0 */4 * * *

Generator

On the hour, every 4 hours

Field by field

  • Minute · 0–59 0 only at minute 0
  • Hour · 0–23 */4 every 4th hour
  • Day of month · 1–31 * every day of the month
  • Month · 1–12 or JAN–DEC * every month
  • Day of week · 0–7 or SUN–SAT * every day of the week

Next runs in your local time

Why this schedule, and when it bites

Four-hourly sits in the heavy-batch territory: six runs a day, enough to keep something moving, light enough that a two-hour import does not overlap the next start. The step anchors to midnight, so the runs fall at 00:00, 04:00, 08:00, 12:00, 16:00 and 20:00. Anything measuring four hours since the last run will be wrong twice a day.

Two gaps are shorter than four hours. From 20:00 the next run is 00:00, a four-hour gap on paper and a shorter one in practice if the 20:00 run started late. When a feed publishes on a strict four-hour grid, an anchored cron and the publisher disagree twice a day unless the job reads timestamps.

The slot is generous; do not spend it. Four hours of headroom invites retries inside the job, which is fine until the retry outlives the slot. Cap the total runtime just below four hours and let the next run pick up leftovers from a queue.

Daylight saving disturbs the 08:00 slot. On the spring-forward night the wall clock jumps; logs keyed to local hour show a different run count that day. Key by UTC when a fixed number of runs matters.

Where this cron expression shows up

  • Backups that are too heavy for every couple of hours
  • Pulling data from a system that publishes a few times a day
  • Cache and index refreshes that people will not notice happening

Common variations

  • Every two hours

    0 */2 * * * On the hour, every 2 hours

  • Every six hours

    0 */6 * * * On the hour, every 6 hours

  • Every four hours inside the working day

    0 8-20/4 * * * On the hour, every 4 hours, between 08:00 AM and 08:00 PM

The step counts from midnight, so the runs are 00:00, 04:00, 08:00, 12:00, 16:00 and 20:00. A job that takes an hour does not shift the next one: the grid stays where it is.

Ranges, steps, and names are spelled out on the cheat sheet.

Questions this schedule raises

Does 0 */4 * * * mean every four hours from midnight?

Yes: 00:00, 04:00, 08:00, 12:00, 16:00, 20:00. Six runs a day, anchored to midnight, not to the previous run.

How do I run every four hours only during the day?

0 8-20/4 * * * gives 08:00, 12:00, 16:00 and 20:00, four runs inside a twelve-hour window. The step still anchors to the start of the range, so the first run is at 08:00.