简体   繁体   中英

How do I schedule a Lambda function to execute everyday only during specific dates?

Is there a way to schedule my Lambda to run everyday ONLY during specific dates? Example:

  • everyday between 1-July to 30-July
  • everyday between 1-Oct to 30-Dec

Also, could I use these dates to set the schedule expression with eventbridge - https://docs.aws.amazon.com/eventbridge/latest/userguide/example_eventbridge_PutRule_section.html ?

You can use the below cron expression to trigger the lambda function between 1-July and to 30-July

0 0 1-30 7 ? *

Explanation of the cron expression:

  • The first field is for minutes (0).
  • The second field is for hours (0).
  • The third field is for days of the month (1-30).
  • The fourth field is for months (7, July).
  • The fifth field is for days of the week (? means every day).
  • The sixth field is for years (* means every year).

You can refer attached image:

事件桥 Cron 表达式配置

You can set up a rule to run an AWS Lambda function on a schedule. Here is a tutorial that shows how to do it.

At a high level, here are the steps.

  1. Create an AWS Lambda Function
  2. Create a Rule via CloudWatch
  3. Verify the Rule

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM