Cron job every 2 hours
The crontab line for a job every 2 hours is 0 */2 * * *. It runs 12 times a day, 4,380 times a year. Edit it below to see the next runs in your time zone.
How 0 */2 * * * reads
The five fields are minute, hour, day of month, month and day of week. A star means every value.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 | minute 00 |
| Hour | */2 | every 2nd hour, starting at 0: 0, 2, 4, 6… |
| Day of month | * | every day of month |
| Month | * | every month |
| Day of week | * | every day of week |
For example, from Wednesday 6 January 2027 at 10:07 the next runs are: Wed 6 Jan 2027, 12:00; Wed 6 Jan 2027, 14:00; Wed 6 Jan 2027, 16:00; Wed 6 Jan 2027, 18:00; Wed 6 Jan 2027, 20:00.
What a job every 2 hours is for
Every 2 hours suits heavier work that should still happen during the day: a partial backup, a full sync with an accounting system, or a crawl of your own site for broken links.
Common mistakes
- «* */2 * * *» runs every minute of every even hour, 60 times. Set the minute: «0 */2 * * *».
- The step starts at hour 0, so the runs are at 00:00, 02:00, 04:00 and so on. For odd hours use «0 1-23/2 * * *».
The same schedule as a systemd timer
On systems with systemd, a timer can replace the crontab line: OnCalendar=0/2:00. Check it with systemd-analyze calendar "0/2:00", which prints the next run.
Know when it didn’t run
Cron doesn’t tell you when a job stops running. Add a heartbeat monitor with a period of 2 hours and end the line with a call to its URL, for example 0 */2 * * * /path/job.sh && curl -fsS -m 10 <ping URL>. If a ping is late by more than the grace time you set, you get an alert, and a call to the URL with /fail reports a failure at once.
What is the cron expression for a job every 2 hours?
0 */2 * * *. It runs 12 times a day, 4,380 times a year, on the server’s clock.
How do I run a job every 2 hours with systemd instead?
Create a timer with OnCalendar=0/2:00 next to a service that runs the job, then enable it with systemctl enable --now name.timer. Persistent=true also runs a run that was missed while the machine was off.