Every hour, on the hour
The simplest recurring schedule after "every minute": minute 0 of every hour — and why the leading 0 is the whole expression.
Last updated
In plain English
- Fires at minute 0 of every hour
- 24 runs per day
Why it’s written this way
Only the minute field is constrained: at minute 0 of any hour, any day, the job fires. Fixing one field and starring the rest is the basic grammar every other schedule builds on.
The rookie version — * * * * * with "hourly" in mind — actually runs every MINUTE. If the minute field is a star, the job fires 60 times an hour.
Edge cases to know
- →Every job on the machine that chose :00 fires together; picking an offset minute (7 * * * *) spreads the load for free.
- →If the job can run longer than an hour, add a lockfile guard — cron happily starts the next run alongside the last.
Part by part
- 0 *
- Minute 0 of every hour. The fixed minute is what makes this hourly rather than continuous, and the wildcard hour is what makes it every hour rather than one.
- * * *
- Day-of-month, month and day-of-week all unrestricted, so the schedule runs every day of the year.
Common mistakes
* * * * *A wildcard in the minute field means every minute, not every hour — sixty times the intended frequency. It is the most expensive single-character difference in cron.
0 * * * *@hourlyNot wrong exactly — it is an accepted shorthand for this same schedule in Vixie cron. It is listed here because it is not universally supported, and a scheduler that merely accepts cron syntax may reject or ignore it.
0 * * * *0 0-23 * * *Spelling out every hour as a range behaves identically to the wildcard but implies a restriction that is not there, so the next reader spends time working out which hours were meant to be excluded.
Questions
Should every hourly job run at minute 0?
No, and it is worth spreading them. Minute 0 is where every default lands, so a machine with several hourly jobs runs them all simultaneously and idles for the other fifty-nine minutes. Staggering them costs nothing.
What happens if one run is still going when the next starts?
Cron starts the new one regardless. For anything that might exceed an hour, take a lock — flock around the command is the usual answer — or you will eventually have several copies competing for the same resource.
Does it run at midnight as well?
Yes. Hour 0 is included in the wildcard, so the schedule fires twenty-four times a day, beginning at 00:00. There is no separate handling of the day boundary.
How do I run every two hours instead?
Use a step in the hour field: 0 */2 * * * fires at even hours. Note that the step counts from 0 rather than from now, so it is 00:00, 02:00, 04:00 and so on, not two hours from whenever you installed it.
Why does my hourly job work by hand but not on schedule?
Almost always the environment. Cron runs with a minimal PATH and none of your shell profile, so a command found on your interactive PATH may simply not exist as far as cron is concerned. Use absolute paths in the command, or source the environment explicitly at the top of the script.