Cron expression for every Sunday at 2 AM
0 2 * * 0The job runs once a week, at 02:00 on Sunday, when most systems are quiet.
Runs when: minute 0; hour 2; every day of month; every month; on Sun.
Change it in the cron expression generatorHow the five fields read
| Field | Value | Reads as |
|---|---|---|
| Minute | 0 | at 0 |
| Hour | 2 | at 2 |
| Day of month | * | every value |
| Month | * | every value |
| Day of week | 0 | at Sunday |
The next five runs
What people use it for
- A weekly maintenance window
- Full backups
- Database vacuuming and reindexing
The daylight saving hour that does not exist
In the US and across Europe the clocks jump forward on a Sunday morning, and in many places 02:00 to 03:00 is the hour that is skipped. A job set for local 02:00 may not run that week, or may run late. Either run the scheduler in UTC, which has no daylight saving, or choose an hour that always exists in your zone.
Variations of every Sunday at 2 AM
| Expression | What it does |
|---|---|
0 3 * * 0 | Sunday at 03:00, after the daylight saving gap. |
0 2 * * 6 | Saturday at 02:00. |
0 2 * * sun | Sunday at 02:00, written with the day name. |
The same schedule in four tools
Linux crontab
0 2 * * 0 /path/to/commandAdd it with crontab -e. It runs in the machine's time zone.
Kubernetes CronJob
spec:
schedule: "0 2 * * 0"
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 2 * * 0'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 2 ? * SUN *)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 Sunday at 2 AM
- Is Sunday 0 or 7?
- Vixie cron accepts both, but some implementations only accept 0, so 0 is the safer choice.
- How do I run it in UTC when the server is not on UTC?
- Set CRON_TZ=UTC at the top of the crontab if your cron supports it, or convert the hour by hand. On a Kubernetes CronJob, set spec.timeZone.
Nearby schedules
- Cron expression for every Monday: Weekly, at the start of the working week.
- Cron expression for the first of every month: Monthly instead of weekly.
- All schedules and the generator
Scheduling jobs, pipelines and cloud infrastructure is part of my DevOps engineering work.