Blog ·
Cron Every 2 Hours: 0 */2 * * * and Other Hourly Schedules
Use 0 */2 * * * to run a cron job every 2 hours. Learn the hourly expression 0 * * * *, business-hours ranges, and how */2 behaves at midnight.
Cron Expression Generator
Build, understand and validate cron expressions.
To run a cron job every 2 hours, use 0 */2 * * *. It fires at minute 0 of hours 0, 2, 4, and so on up to 22, every day. For hourly jobs, use 0 * * * *. You can build and preview these with the Cron Expression Generator, which shows upcoming run times so you can confirm the schedule before deploying it.
This post covers the 5-field format used by standard crontab, the most common every-N-hours patterns, business-hours ranges, and a few pitfalls that catch people out.
The 5 fields in order
A standard cron expression has five fields separated by spaces:
minute hour day-of-month month day-of-week
Valid values are 0-59 for minute, 0-23 for hour, 1-31 for day of month, 1-12 for month, and 0-7 for day of week, where both 0 and 7 mean Sunday. For hour-based schedules, only the first two fields matter. Set the other three to * to mean every value.
Hourly: every hour on the hour
The expression for once per hour is:
0 * * * *
The minute field is 0, so the job runs at :00 of every hour. The hour field is *, so it runs in every hour. That gives 24 runs per day.
Minute 0 versus minute 30
The minute field sets where in the hour the job runs. These two expressions both run hourly, but at different times:
0 * * * * 30 * * * *
The first runs at 1:00, 2:00, 3:00 and so on. The second runs at 1:30, 2:30, 3:30. If many jobs on a host or in a queue are scheduled at :00, they all compete at the same moment. Offsetting a job to a less crowded minute, such as 17 or 30, can reduce that contention. Pick the minute based on what else runs on the same system.
Every 2 hours and every N hours
Use a step value after the asterisk in the hour field. The step */N means every Nth value, counting from the start of the range (0 for hours).
0 */2 * * * 0 */3 * * * 0 */4 * * * 0 */6 * * * 0 */12 * * *
Here is what each one runs:
- 0 */2 * * *: 00:00, 02:00, 04:00, ..., 22:00 (12 runs per day)
- 0 */3 * * *: 00:00, 03:00, 06:00, ..., 21:00 (8 runs per day)
- 0 */4 * * *: 00:00, 04:00, 08:00, 12:00, 16:00, 20:00 (6 runs per day)
- 0 */6 * * *: 00:00, 06:00, 12:00, 18:00 (4 runs per day)
- 0 */12 * * *: 00:00 and 12:00 (2 runs per day)
Why */2 does not run at 23:00
The hour field counts from 0 at midnight. Since 23 is not a multiple of 2, the job skips it. The last run of the day is 22:00, and the next is 00:00 the following day. The gap across midnight is 2 hours, the same as every other gap.
This works cleanly only because 24 divides evenly by 2. The schedule restarts at 0 every day, so it repeats the same way each day. It does not carry over an offset from the previous day.
The problem shows up when the step does not divide 24. Compare these:
0 */5 * * * # runs 0, 5, 10, 15, 20, then 0 again: 4-hour gap at night 0 */7 * * * # runs 0, 7, 14, 21, then 0 again: 3-hour gap at night
With */5, you get 00:00, 05:00, 10:00, 15:00, 20:00, and then 00:00 again. The gap from 20:00 to 00:00 is 4 hours, not 5. With */7, the gap from 21:00 to 00:00 is 3 hours. When N does not divide 24, the gap that wraps past midnight is always shorter than N. The other gaps are exactly N. So the job runs a little more often than every N hours around midnight, and the pattern repeats the same way each day.
If you need strictly even spacing across days, use a scheduler that supports interval-based timers, or run the job from a loop or a system that tracks the last run time.
Business-hours ranges
Use a range like 9-17 in the hour field to run only during specific hours. Ranges are inclusive, so 9-17 includes both 9:00 and 17:00, giving 9 runs.
0 9-17 * * * # top of every hour from 09:00 to 17:00 0 9-17/2 * * * # every 2 hours from 09:00 to 17:00: 9, 11, 13, 15, 17 0 9-17 * * 1-5 # hourly 09:00-17:00, Monday to Friday 0 9-17/2 * * 1-5 # every 2 hours, 09:00-17:00, Monday to Friday
In the day-of-week field, 1-5 means Monday through Friday, with 0 or 7 as Sunday. If you want the job to run on weekends too, leave that field as *.
Ranges with steps, such as 9-17/2, are supported by most standard cron implementations. Some schedulers built into languages or frameworks use a different syntax, often with a seconds field at the start. Check your scheduler's documentation before copying an expression across systems.
Common mistakes
- Using */2 in the minute field instead of the hour field. */2 in minutes means every 2 minutes, which is far more often than most people intend. Use 0 */2 * * * for every 2 hours.
- Forgetting the minute field. Writing */2 * * * * runs every 2 minutes. Always put a fixed minute value, usually 0, in front of an hour step.
- Assuming the server timezone is your local time. Cron uses the system timezone of the machine running it, which is often UTC on servers. Confirm this before you schedule a job for a specific local hour.
- Expecting clean behavior across daylight saving time changes. On days when clocks change, local-time schedules can skip or repeat an hour, depending on the implementation. For jobs where this matters, schedule in UTC.
- Testing by waiting. Preview the next several run times before deploying. The Cron Expression Generator shows upcoming runs for an expression, which is faster than checking logs the next day.
If your job runs once a day rather than hourly, see Cron Every Day at Midnight. For minute-based intervals, see Cron Every 5 Minutes. For weekday-specific schedules, see Cron Every Monday.
Quick reference
- Every hour on the hour: 0 * * * *
- Every hour at half past: 30 * * * *
- Every 2 hours: 0 */2 * * *
- Every 3 hours: 0 */3 * * *
- Every 6 hours: 0 */6 * * *
- Hourly during business hours: 0 9-17 * * 1-5
- Every 2 hours during business hours: 0 9-17/2 * * 1-5
FAQ
Does 0 */2 * * * run at midnight?
Yes. The hour field starts at 0, so the first run each day is 00:00. The runs continue at 02:00, 04:00, and so on until 22:00.
How do I run a job every 90 minutes with cron?
Standard cron has no way to express 90-minute intervals directly, because 90 minutes does not divide evenly into an hour or a day. Use a loop in your script, a systemd timer, or a scheduler that supports interval triggers.
Can I run a job every 2 hours but only at odd hours?
Yes. Use 0 1-23/2 * * *, which runs at 01:00, 03:00, 05:00, and so on until 23:00. Starting the range at 1 makes the schedule odd-hour instead of even-hour.
Why does my cron job run at the wrong hour?
The most common cause is timezone. Cron uses the server's system timezone, which is often UTC. Check the timezone setting on the machine, and compare the next run times you expect with what the scheduler actually does.
Cron Expression Generator
Build, understand and validate cron expressions.