AWS EventBridge cron
Amazon EventBridge (and CloudWatch Events) does not use five-field crontab. cron() has minutes, hours, day-of-month, month, day-of-week, and year. You must put ? in either day-of-month or day-of-week — never * in both.
Field format
cron(minutes hours day-of-month month day-of-week year)
Gotchas
- Why does AWS reject * * * * *?
- That is five-field crontab. EventBridge wants six fields and a ? in one of the day slots, for example cron(0 9 ? * MON *).
- When should I use rate() instead?
- rate(5 minutes) is clearer for even intervals. Use cron() when you need a wall-clock hour or a day of week.
Examples
Every weekday at 09:00 UTC
0 9 * * 1-5Open this scheduleOnce a day at midnight UTC
0 0 * * *Open this scheduleEvery 10 minutes
*/10 * * * *Open this schedule
Snippet for AWS EventBridge
GitHub Actions
UTC only. Quote the expression so YAML keeps the stars.
on:
schedule:
- cron: '0 9 * * 1'Kubernetes
CronJob spec.schedule. Kubernetes uses the timezone of the kube-controller-manager unless you set .spec.timeZone.
apiVersion: batch/v1
kind: CronJob
metadata:
name: job
spec:
schedule: "0 9 * * 1"
jobTemplate:
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
args: ["echo", "run"]AWS EventBridge
Six fields: minutes hours day-of-month month day-of-week year. Use ? in either day-of-month or day-of-week.
cron(0 9 ? * 1 *)Quartz
Quartz is seconds-first (6 or 7 fields). Day-of-week names are MON, TUE, … and ? is required in one of the day fields.
0 0 9 * * 1Vercel Cron
{
"crons": [
{
"path": "/api/cron",
"schedule": "0 9 * * 1"
}
]
}crontab
0 9 * * 1 /usr/local/bin/jobnode-cron
import cron from 'node-cron';
cron.schedule('0 9 * * 1', () => {
// job
});Spring @Scheduled
Spring uses 6 fields by default (seconds first) unless you set spring.task.scheduling.cron.expression.
@Scheduled(cron = "0 0 9 * * 1")
public void run() {
// job
}