The expression
0 0 1 * *
Runs at 00:00 on the 1st of every month: twelve times a year.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 |
at minute 0 |
| Hour | 0 |
at midnight |
| Day of month | 1 |
the 1st |
| Month | * |
every month |
| Day of week | * |
any day of the week |
The 1st exists in every month, so unlike the 29th, 30th or 31st it never gets skipped. This is the same schedule as the @monthly macro; see every month for picking another day.
First weekday, first Monday
The 1st is often a Saturday or a holiday, and people then ask for "the first Monday" or "the first business day". The obvious line is wrong:
0 9 1-7 * 1 # NOT the first Monday
When both day of month and day of week are restricted, cron runs when either matches, so this fires on the 1st to 7th of every month and on every Monday. Schedule one of the two and test the other in the command:
0 9 1-7 * * [ "$(date +\%u)" = 1 ] && /usr/local/bin/invoice.sh
date +%u prints 1 for Monday through 7 for Sunday; inside a crontab, % must be escaped as \%. For the first weekday of the month (Monday to Friday):
0 9 1-3 * * [ "$(date +\%u)" -le 5 ] && [ "$(date +\%d)" = 01 -o "$(date +\%u)" = 1 ] && /usr/local/bin/job.sh
That runs on the 1st if it's a weekday, otherwise on the Monday that follows (the 2nd or 3rd). Quartz and AWS have this built in as 1W (the weekday nearest the 1st, never crossing into the previous month).
Variants
| Schedule | Expression |
|---|---|
| 1st of the month at 6am | 0 6 1 * * |
| 1st and 15th | 0 0 1,15 * * |
| Last day of the month | 0 0 28-31 * * plus a test |
| First day of each quarter | 0 0 1 1,4,7,10 * |
| 1 January only | 0 0 1 1 * |
Where to write it
- crontab (Linux, macOS):
0 0 1 * * commandor@monthly commandincrontab -e, in the server's time zone. - GitHub Actions:
cron: '0 0 1 * *'is midnight UTC on the 1st, still the last day of the previous month in the Americas. Midnight UTC on the 1st is one of the busiest moments for scheduled workflows, so a later hour like0 6 1 * *starts more reliably. - Kubernetes CronJob:
schedule: "0 0 1 * *"withtimeZone:. - AWS EventBridge:
cron(0 0 1 * ? *), with?in the day-of-week field;cron(0 9 1W * ? *)for the first weekday.
Common mistakes
* * 1 * *runs every minute of the 1st. Fix the minute and hour.0 0 1 * 1. The OR rule again: every 1st and every Monday.
See the next twelve months in the Cron Expression Parser.