The expression
0 17 * * 5
Runs once a week, on Friday at 17:00.
| Field | Value | Meaning |
|---|---|---|
| Minute | 0 |
at minute 0 |
| Hour | 17 |
at 5pm (24-hour clock) |
| Day of month | * |
any day |
| Month | * |
every month |
| Day of week | 5 |
Friday |
Cron has no am/pm: hours run from 0 to 23, so 5pm is 17 and 5 would be 5 in the morning. Friday is 5 in standard cron (Sunday 0, Monday 1 … Saturday 6), and 0 17 * * FRI is the same thing.
Variants
| Schedule | Expression |
|---|---|
| Friday at 5:30pm | 30 17 * * 5 |
| Friday at 4pm (before people leave) | 0 16 * * 5 |
| Every weekday at 5pm | 0 17 * * 1-5 |
| Monday at 9am | 0 9 * * 1 |
| Friday 13th only | 0 17 13 * * plus [ "$(date +\%u)" = 5 ] |
| The last Friday of the month | 0 17 * * 5 plus [ "$(date -d '+7 days' +\%d)" -le 7 ] |
The last row runs the job every Friday and lets the command check that next Friday falls in a new month (its day of month is 7 or less). In a crontab line % has to be escaped as \%. On Quartz-based schedulers and AWS the same thing is built in: 6L (Quartz numbers Friday as 6) means the last Friday.
Where to write it
- crontab (Linux, macOS):
0 17 * * 5 /usr/local/bin/weekly-summary.shincrontab -e. 17:00 is the server's local time; setCRON_TZ=at the top of the file where supported. - GitHub Actions:
on: schedule: - cron: '0 17 * * 5'runs at 17:00 UTC: 18:00 in London in winter, 19:00 in Berlin in summer, 13:00 in New York in summer. Pick the UTC hour that matches your office, and remember it moves an hour with daylight saving. - Kubernetes CronJob:
schedule: "0 17 * * 5"withtimeZone: "America/Chicago"(or your zone). - AWS EventBridge:
cron(0 17 ? * FRI *). Day of month must be?; Friday is6in EventBridge's 1 = Sunday numbering, so use the name.
Common mistakes
0 5 * * 5runs at 5am. Use17for the afternoon.- Friday the 13th as
0 17 13 * 5. Because cron ORs the day fields when both are restricted, that runs on every Friday and on every 13th. Schedule one field and test the other in the command, as in the table. - Deploying on Friday at 5pm. A scheduled job that fails at the start of the weekend may go unnoticed until Monday. Send its failures somewhere people look, or move it earlier.
Check the next Fridays in the Cron Expression Parser.