Cron expression for every hour
Runs the job once an hour, at the top of the hour.
0 * * * *
Every hour
Field by field
- Minute · 0–59
0only at minute 0 - Hour · 0–23
*every 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
The hourly schedule is the backbone of reporting: aggregate the last hour, refresh a snapshot, mail a digest. 0 * * * * is not the same as * * * * * despite the similar shape; the leading 0 pins the run to minute zero and turns sixty fires an hour into one. It is also the schedule most often mismatched with its consumers: reports that promise fresh data every hour still need a late-arrival grace window before they sum.
Minute zero is shared by half the crontab. At :00 the hourly job meets every */15 and */30 job and the daily ones. If the job is heavy, shift it to :05 or give each host a random minute in large fleets; the reports do not care about five minutes, the database does.
The last hour is not complete at the top of the hour. Events written at 13:59:58 by a lagging service land after the 14:00 run read its window. Either close the window at :55 or re-run a correction job. Otherwise the hourly numbers drift low and the monthly reconciliation blames the report.
DST eats one run per year. On the spring-forward night the 02:00 run does not exist; on fall-back the 01:00 hour repeats. Hourly aggregations keyed by wall-clock hour either double-count or skip. Key by UTC hour in the database, and let the mailer format the local time.
Where this cron expression shows up
- Hourly reports
- Aggregating the last hour of events
- Refreshing a snapshot other services read
Common variations
-
Every hour at half past
30 * * * * At 30 minutes past the hour
-
Every six hours
0 */6 * * * On the hour, every 6 hours
Ranges, steps, and names are spelled out on the cheat sheet.
Questions this schedule raises
Does 0 * * * * run at the start of every hour?
Yes. It fires once per hour, at minute 0. Writing 0 */1 * * * is the same schedule with more noise; * * * * * would mean every minute, which is the classic misread.
How do I run every hour but only between 8 AM and 8 PM?
0 8-20 * * * fires at 08:00 through 20:00, thirteen runs a day. The hour field is inclusive, and the job hears nothing overnight, which is exactly what a business-hours digest wants.