skip to Main Content

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?

2

Answers


  1. 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

    EventBridge

    Login or Signup to reply.
  2. 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 *
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search