Cron expression for every 2 hours
0 */2 * * * runs a job every two hours, on the hour: at midnight, 2:00, 4:00 and so on through 22:00.
Runs entirely in your browser. Nothing you paste is sent to our server, stored or logged.
0 */2 * * *
When it runs next
What it means
The step in the hour field counts from midnight, so the runs always fall on even hours, 12 times a day. Leaving the minute as an asterisk is the usual mistake: * */2 * * * runs every minute of every even hour, which is 720 runs a day instead of 12.
For odd hours, use a range with a step. 0 1-23/2 * * * runs at 1:00, 3:00 and so on. The same pattern works for any interval that divides into 24, so every 3, 4, 6 or 12 hours is just a different number after the slash.
Common variations
| Expression | Runs |
|---|---|
0 */3 * * * | Every three hours |
0 1-23/2 * * * | Every two hours, on the odd hours |
0 8-18/2 * * 1-5 | Every two hours from 8:00 to 18:00 on weekdays |
As a crontab line
Add the command you want to run after the five fields, then save it with
crontab -e:
0 */2 * * * /path/to/script.sh