The expression
0 0 * * 0
Runs once a week, at 00:00 on Sunday. That is what the @weekly macro means, so in a crontab these two lines are identical:
@weekly /usr/local/bin/cleanup.sh
0 0 * * 0 /usr/local/bin/cleanup.sh
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 |
at minute 0 |
| Hour | 0 |
at midnight |
| Day of month | * |
any day |
| Month | * |
every month |
| Day of week | 0 |
Sunday (7 also works) |
Picking the day and hour
"Once a week" just needs a single value in the day-of-week field and a fixed minute and hour. Sunday at midnight is only the convention behind @weekly; any day works:
| Schedule | Expression |
|---|---|
Sunday at midnight (@weekly) |
0 0 * * 0 |
| Monday at midnight | 0 0 * * 1 |
| Monday at 9am | 0 9 * * 1 |
| Friday at 5pm | 0 17 * * 5 |
| Wednesday at 3:15am | 15 3 * * 3 |
| Every two weeks | needs a workaround |
Choosing an off-peak, slightly odd time such as 15 3 * * 3 keeps a weekly job away from the crowd of jobs that all start at Sunday 00:00.
Where to write it
- crontab (Linux, macOS):
@weekly commandor0 0 * * 0 commandincrontab -e, in the server's time zone. Many distributions also run scripts dropped into/etc/cron.weekly/once a week (through anacron orrun-parts), which catches up if the machine was off at the scheduled time. - GitHub Actions:
on: schedule: - cron: '0 0 * * 0'. Macros like@weeklyare not accepted; times are UTC. In a public repository, scheduled workflows are disabled after 60 days without repository activity, which a weekly job in a quiet repo can hit. - Kubernetes CronJob:
schedule: "@weekly"or"0 0 * * 0", withtimeZone:to set the zone. - AWS EventBridge:
cron(0 0 ? * SUN *), orrate(7 days). A rate counts from when the rule was created, so it runs every 7 days at that time of day rather than on a fixed weekday.
Common mistakes
* * * * 0is not weekly. It runs every minute all Sunday: 1,440 times. Fix the minute and hour.- Assuming
@weeklymeans Monday. It's Sunday at 00:00 in every standard implementation. - A machine that sleeps. Plain cron skips runs while the computer is off; on laptops and desktops use
/etc/cron.weekly, anacron or a systemd timer withPersistent=true.
Paste it into the Cron Expression Parser to see the next weekly runs.