Reputation: 14773
How can I run a cron job at 2am UTC at every Sunday and Wednesday on AWS.
0 2 * * SUN,WED *
The time is fine, just the days seem to be the wrong format (getting Parameter ScheduleExpression is not valid
via serverless). But all resources I can find do only state ranges of days, how to select single ones?
Upvotes: 2
Views: 3275
Reputation: 462
From AWS documentation:
Limitations
You can't specify the Day-of-month and Day-of-week fields in the same cron expression. If you specify a value or a * (asterisk) in one of the fields, you must use a ? (question mark) in the other.
Cron expressions that lead to rates faster than 1 minute are not supported.
The correct way should be:
0 2 ? * SUN,WED *
Upvotes: 1
Reputation: 59960
Your cron should look like this:
0 2 ? * SUN,WED *
Or:
0 2 ? * 1,4 *
^
Day of month is wrong
Your issue is with the Day of month.
Check the result in EventBridge
Upvotes: 4