05 / Know the syntax
Crontab syntax: the five cron fields
A standard cron expression has minute, hour, day-of-month, month, and day-of-week fields. It describes wall-clock matches, not a fixed elapsed interval. AWS Scheduler adds a sixth field for the year.
Read from left to right
┌────── minute 0–59
│ ┌──── hour 0–23
│ │ ┌── day of month 1–31
│ │ │ ┌ month 1–12
│ │ │ │ ┌ day of week
* * * * *
Sunday is 0 in standard cron (Linux also accepts 7). AWS uses 1 for Sunday through 7 for Saturday. Names such as MON and JAN reduce ambiguity.
Use the building blocks
*- Every value in a field
,- A list:
0,15,30,45 -- An inclusive range:
MON-FRI /- A step:
*/15 or 9-17/2 ?- AWS: leave one day field unspecified. Kubernetes: wildcard.
*/35 in minutes means minute 0 and 35 of each hour. The gaps alternate between 35 and 25 minutes.
Handle calendar boundaries
With standard cron, restricting both day fields matches either one. 0 9 1 * MON runs on the first of the month and every Monday.
AWS requires exactly one day field to be ?. It also supports L (last), W (nearest weekday), and # (nth weekday), for example MON#2.
A day that does not exist never matches. Use L in AWS mode for the last day of every month.