How create rule in AWS with CRON expression

973 Views Asked by At

I want to create a scheduled expression, which will start js script every week at 5:30PM PT using CloudWatch Events. I tried to insert:

- 0 30 3 * * THU *  
- 0 30 3 THU 

But got

Error
There was an error while saving rule getEvery1min.
Details: Parameter ScheduleExpression is not valid..

Can you help me pls?

2

There are 2 best solutions below

2
On

The cron expression should be in the below format

"Minutes" "Hours" "Day of month" "Month" "Day of week" "Year"

Based on the above cron it appears you're trying to run the cron expression only on Thursdays on the third day of the month. However if you want it to run once a week at 5:30pm you'd want something like the below.

30 17 * * THU *

Also take care to remember this expression is in UTC, so you would need to adjust it for your timezone.

For more information take a look at the Scheduled Events documentation.

0
On

According the docs - Schedule Expressions for Rules

Only this is work - 30 17 ? * THU *

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 *) in one of the fields, you must use a ? (question mark) in the other.