0 */6 * * * runs at minute 0 of every sixth hour: 00:00, 06:00, 12:00 and 18:00. The cron parser summarises it as “Every 6 hours” and expands the hour field to 0,6,12,18. Four runs a day, always at the same clock times.
How the pieces fit
- The minute field is
0, so the job starts on the hour. If you wrote* */6 * * *it would run every minute within those four hours (240 times a day) — an easy slip when you tweak an existing expression. - The hour field
*/6takes every sixth value of0-23: 0, 6, 12, 18. - Everything else is
*: every day, every month, every weekday.
Compare with the neighbours: 0 */4 * * * (every four hours: 0, 4, 8, 12, 16, 20), 0 */12 * * * (twice a day) and 0 */8 * * * (0, 8, 16).
Steps are even only if they divide 24
A step restarts each day. */6, */4, */3, */8 and */12 all divide 24, so the gaps are equal. */5 does not: 0 */5 * * * runs at 0, 5, 10, 15 and 20, then at 0 again, so the last gap is four hours. The parser lists the actual runs, which makes this visible. If you need an exact interval that does not divide 24, make the job check how long ago it last ran.
Clock times, not intervals
Cron works from the calendar. “Every 6 hours” really means “at these four times of the day”. It is not “six hours after the previous run finished”. This matters in two ways:
- If a run takes 7 hours, the next one starts at the scheduled time, while the first is still going. Use
flock(see every minute) to prevent an overlap. - If the computer is off at 06:00, the run is lost. Cron (unlike anacron) does not run missed jobs when it comes back.
For a gap that is measured from the last start or end, use a systemd timer (OnUnitActiveSec=6h or OnUnitInactiveSec=6h).
Choose the right times
You are free to list the hours. For example, to run backups at 03:15 and 15:15 outside the busy periods:
15 3,15 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1
Whatever you choose, remember that the hours are in the server’s time zone. A server in UTC runs 0 */6 at 07:00, 13:00, 19:00 and 01:00 in Hanoi (UTC+7). It has no daylight saving there, so the pattern stays steady all year; in a zone with a daylight saving change, the hour of the clock change can run twice or be skipped. See cron and time zones.
Related
For an hourly job, read every hour; for a daily one, daily at midnight. The cron builder will assemble the expression, and you can check the result against the parser before you save it.
Frequently asked questions
What is the cron expression for every 6 hours?
0 */6 * * *. It runs at 00:00, 06:00, 12:00 and 18:00 in the time zone of the cron daemon. If you want other times of day, list them: 0 3,9,15,21 * * *.
Why must the minute be 0 and not a star?
A star in the minute field means every minute. */6 * * * * would run every 6 minutes. Write 0 in the minute field, and put the step in the hour field.
Does cron wait six hours after the previous job finished?
No. Cron follows the clock, not the end of the last run. For 'six hours after the last run' use a systemd timer with OnUnitActiveSec=6h, or let the job save its last time and decide for itself.
Why is the gap uneven with 0 */5 * * *?
The hour step restarts at midnight, so the runs are at 0, 5, 10, 15 and 20 o'clock, then 0 again, with only four hours at the end. Steps are even only when they divide 24 (2, 3, 4, 6, 8, 12).
More in this reference
- Cron daily at midnight (0 0 * * *): @daily, time zones and a better hour
- Cron every 5 minutes (*/5 * * * *): syntax, the step operator and its limits
- Cron every 15 minutes (*/15 * * * *): quarter hours and staggered starts
- Cron every hour (0 * * * *): @hourly, and the mistake of * 0 * * *
- Cron every minute (* * * * *): how it works and the traps
- Cron every Monday at 9 AM (0 9 * * 1) and the day-of-month OR trap
- Cron on the first day of the month (0 0 1 * *): @monthly and its limits
- Cron on the last day of the month: why there is no L, and three working solutions
- Cron on weekdays at 9 AM (0 9 * * 1-5): Monday to Friday