Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cloudwatch Rule Schedule Cron Expression to Skip 2 Hours in a Day

I want to trigger an AWS Lambda function, using Cloudwatch Rules and the requirement is as follows.

  • Condition 1: Trigger Daily
  • Condition 2: Every 5 mins
  • Condition 3: It should NOT trigger between 11PM and 1AM every day (Maintenance Window).

I read the documentation on crons and am unable to come up with a Cron expression to fulfill condition 3. I came up with the following expression.

0/5 ## * * ? *

How can I fulfill condition 3 mentioned above? I have left it as ## on the cron expression. I am well aware of the timezones.

like image 528
Keet Sugathadasa Avatar asked Jan 01 '23 09:01

Keet Sugathadasa


1 Answers

You can utilize cron online tools such as

https://crontab.guru/

http://www.cronmaker.com/

Here is the expression that I created as per your requirement

*/5 1-23 * * *

enter image description here

like image 156
Juned Ahsan Avatar answered Jan 08 '23 00:01

Juned Ahsan