The expression
0 */4 * * *
Runs at minute 0 of hours 0, 4, 8, 12, 16 and 20: six times a day. Since 24 divides evenly by 4, every gap is exactly 4 hours, including 20:00 to 00:00.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 |
at minute 0 |
| Hour | */4 |
every 4th hour, starting at 0 |
| Day of month | * |
every day |
| Month | * |
every month |
| Day of week | * |
every day of the week |
The equivalent list form is 0 0,4,8,12,16,20 * * *. The step is anchored to midnight, not to when you installed the job.
Variants
| Schedule | Expression |
|---|---|
| Every 4 hours from 2:00 (2, 6, 10, 14, 18, 22) | 0 2-23/4 * * * |
| Every 4 hours from 1:00 (1, 5, 9, 13, 17, 21) | 0 1-23/4 * * * |
| Every 4 hours at 30 past | 30 */4 * * * |
| Every 4 hours during the day (8, 12, 16, 20) | 0 8-20/4 * * * |
| Every 4 hours on weekdays | 0 */4 * * 1-5 |
| Every 3 hours | 0 */3 * * * |
| Every 6 hours | 0 */6 * * * |
| Every 12 hours | 0 */12 * * * |
An offset like 2-23/4 is handy when other jobs already run at midnight: the 4-hour cadence stays the same, but the heavy work moves away from 00:00.
Where to write it
- crontab (Linux, macOS):
0 */4 * * * /usr/local/bin/refresh-cache.shincrontab -e. Hours are in the server's time zone; check it withtimedatectlordate. - GitHub Actions:
on: schedule: - cron: '0 */4 * * *'. Always UTC. GitHub warns that the start of every hour is a high-load time, so13 */4 * * *is less likely to be delayed. - Kubernetes CronJob:
schedule: "0 */4 * * *", plustimeZone: "Asia/Tokyo"(or yours) to run on local hours. - AWS EventBridge:
cron(0 0/4 * * ? *)in six fields with?for day of week, orrate(4 hours), counted from when the rule was created.
Common mistakes
0 4 * * *is once a day, at 04:00. Without the slash it's a single hour.*/4 * * * *runs every 4 minutes, 360 times a day.- Forgetting the minute.
* */4 * * *runs every minute for the whole hour, six times a day. - Time zone surprises. "Every 4 hours from midnight" on a UTC host is not midnight locally. Convert, or set
timeZone/CRON_TZ.
Paste any expression into the Cron Expression Parser to see it in words and its next run times.