Cron expression for every 2 hours
Runs the job on every even hour, twelve times a day.
0 */2 * * *
On the hour, every 2 hours
Field by field
- Minute · 0–59
0only at minute 0 - Hour · 0–23
*/2every 2nd 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
Two-hourly is the rhythm of near-real-time without the per-minute bill: twelve runs a day, a queue that drains every couple of hours, a report that refreshes while people still care. The step sits in the hour field and counts even hours from midnight, which is why the next run after 23:59 is midnight, not two hours later.
Even hours, not every two hours. 0 */2 fires at 0, 2, 4 and so on regardless of when the previous run ended. A job that needs exactly two hours between starts must measure elapsed time itself; cron will start it at 02:00 anyway.
Midnight absorbs two runs. At the day boundary you get the 22:00 run and then the 00:00 run of the next day. Any bucket keyed by local date sees two runs in the same minute of the calendar. Bucket by the timestamp the run writes, not by the date the cron started.
Twelve retries a day can hide an outage. A flapping integration that fails every other run looks healthy at a glance if you count successes. Alert on the ratio over a day, or a two-hourly job will mask an eight-hour outage as routine.
Where this cron expression shows up
- Pulling a report from a service that only updates every couple of hours
- Backups that are too heavy to run hourly
- Reconciliation jobs that can wait until the next even hour
Common variations
-
Every four hours
0 */4 * * * On the hour, every 4 hours
-
Every six hours
0 */6 * * * On the hour, every 6 hours
-
Every two hours during working hours only
0 8-18/2 * * * On the hour, every 2 hours, between 08:00 AM and 06:00 PM
The step lives in the hour field, so it fires on the even hours and starts again at midnight. 0 */2 * * * at 11:59 PM runs the next job at midnight, not two hours later.
Ranges, steps, and names are spelled out on the cheat sheet.
Questions this schedule raises
Is 0 */2 * * * every two hours starting now?
No, it anchors to midnight: runs at 00:00, 02:00, 04:00 and so on. Deploying at 09:15 does not shift the first run to 09:15; the next is 10:00.
How do I get an odd hour offset?
Move the minute, not the hour: 30 */2 * * * fires at 00:30, 02:30 and so on, keeping the two-hour rhythm while avoiding the top-of-hour crowd.