Field by field
* * * * * reads: Every minute. That is 1,440 runs a day.
| Field | Value | Selects |
|---|---|---|
| Minute | * | every minute |
| Hour | * | every hour |
| Day of month | * | any day of the month |
| Month | * | every month |
| Day of week | * | any day of the week |
Worth knowing
- 1,440 runs a day. If one run can take longer than a minute, runs overlap: guard the job with a lock (
flock -n) or it will pile up. - GitHub Actions will not run a schedule more often than every 5 minutes, so this becomes every 5 minutes there at best.
- Cron cannot go below a minute. For every 30 seconds, run two entries - one plain, one that starts with
sleep 30;- or use a timer.
Variations
* 9-17 * * 1-5Every minute, but only during office hours on weekdaysExplain it*/2 * * * *Every other minuteExplain it
The same schedule elsewhere
crontab
* * * * * /path/to/job.sh
Runs in the machine's local timezone. crontab -e to edit.
GitHub Actions
on:
schedule:
- cron: "* * * * *"Always UTC. Nothing more often than every 5 minutes, and runs can start late when GitHub is busy.
Kubernetes CronJob
spec: schedule: "* * * * *" timeZone: "Asia/Kolkata"
timeZone needs Kubernetes 1.27 or later; without it the controller's zone applies, usually UTC.
Spring @Scheduled
@Scheduled(cron = "0 * * * * *")
Six fields: seconds come first. Days are written as names, which Spring and cron read alike.
Quartz
0 * * * * ?
One of day-of-month and day-of-week must be ?. Quartz counts days 1-7 from Sunday, so names are safer than numbers.
AWS EventBridge
cron(* * * * ? *)
Six fields, the last one the year. UTC unless the schedule sets a timezone. Days count from Sunday, as in Quartz.
systemd timer
[Timer] OnCalendar=*-*-* *:*:00 Persistent=true
Persistent=true runs a job that was missed while the machine was off, once it is back.