Cron expression for every 6 hours
0 */6 * * *The job runs at minute 0 of hours 0, 6, 12 and 18, four times a day.
Runs when: minute 0; every 6 hours; every day of month; every month; any day of week.
Change it in the cron expression generatorHow the five fields read
| Field | Value | Reads as |
|---|---|---|
| Minute | 0 | at 0 |
| Hour | */6 | every 6 hours |
| Day of month | * | every value |
| Month | * | every value |
| Day of week | * | every value |
The next five runs
What people use it for
- Refreshing a data warehouse extract
- Rotating and compressing logs
- Syncing a supplier or product feed
The hours are fixed to the clock
*/6 in the hour field always means 0, 6, 12 and 18, whatever time you deployed it. To move the whole pattern, give the field a start: 0 2-23/6 * * * runs at 02:00, 08:00, 14:00 and 20:00. Remember too that those hours are in the scheduler's time zone, so a server on UTC fires at 00:00 UTC, which is 05:00 in a UTC+5 time zone such as Pakistan.
Variations of every 6 hours
| Expression | What it does |
|---|---|
0 2-23/6 * * * | Every 6 hours starting at 02:00: 02:00, 08:00, 14:00 and 20:00. |
30 */6 * * * | Every 6 hours at :30 past: 00:30, 06:30, 12:30 and 18:30. |
0 */8 * * * | Every 8 hours instead: 00:00, 08:00 and 16:00. |
The same schedule in four tools
Linux crontab
0 */6 * * * /path/to/commandAdd it with crontab -e. It runs in the machine's time zone.
Kubernetes CronJob
spec:
schedule: "0 */6 * * *"
timeZone: "Etc/UTC"
concurrencyPolicy: ForbidtimeZone is stable from Kubernetes 1.27. Without it, the controller's time zone applies. Forbid stops a new run starting while the last one is still going.
GitHub Actions
on:
schedule:
- cron: '0 */6 * * *'Schedules run in UTC from the default branch, and a run can start a few minutes late when GitHub is busy. Scheduled workflows in public repositories are disabled after 60 days without repository activity.
AWS EventBridge
cron(0 0/6 * * ? *)EventBridge uses six fields, with a question mark in one of the two day fields, and rules run in UTC. Weekday numbers start at Sunday = 1, so names such as MON are safer than numbers.
Questions about every 6 hours
- Why does every 5 hours behave oddly?
- 24 does not divide by 5, so 0 */5 * * * runs at 00:00, 05:00, 10:00, 15:00 and 20:00, then starts over at 00:00. The last gap is four hours, not five.
- Can it start counting from the time I deployed?
- No. Cron is tied to the clock, not to when the job was created. If you need an interval measured from a start time, use a scheduler with a rate or interval setting.
Nearby schedules
- Cron expression for every hour: Twenty-four runs a day.
- Cron expression for twice a day: Two runs a day, at hours you choose.
- All schedules and the generator
Scheduling jobs, pipelines and cloud infrastructure is part of my DevOps engineering work.