JAN
JAN

Reputation: 21865

Cron formula for every Sunday 00:01:00 and Saturday 23:59:00

We need to set 2 formulas for AWS Lambda :

1) Every Saturday 23:59:00

schedule: cron(0 59 23 ? * SAT *)

2) At 00:01:00am, on every Sunday, every month

schedule: cron(0 1 0 ? * SUN *)

We put both in the YAML file however they didn't trigger (but worked manually).

How can I verify their correctness ?

Upvotes: 0

Views: 1741

Answers (2)

Ethan Harris
Ethan Harris

Reputation: 1362

Hard to say what is wrong without viewing your Cloudformation template, but your yml file should resemble something like this:

functions:   test:
    handler: lambda_function.lambda_handler
    description: "test serverless Lambda"
    memorySize: 128
    timeout: 300
    events:
      - schedule:
        rate: cron(59 23 ? * SAT *)
        enabled: true
        input:
          key: value
      - schedule:
        rate: cron(00 01 ? * Sun *)
        input: '{"key": "value"}'
        enabled: true

Upvotes: 1

Arun Kamalanathan
Arun Kamalanathan

Reputation: 8583

It should be cron(59 23 ? * SAT *) and remember the timezone cron uses is GMT. You have to set the GMT time that matches your timezone.

For sunday one it should be cron(00 01 ? * Sun *).

A cron event for lambda is basically a cloudwatch event. You can view the correctness of your cron in the cloudwatch event itself. it will show you the next 10 occurrences of the cron as you modify it.

Hope this helps. good luck

Upvotes: 1

Related Questions