Happy Machine
Happy Machine

Reputation: 1163

cron expression failing on aws lambda

I want this endpoint to be hit every ten minutes apart from on sunday

I've tried

cron(5,15,25,35,45,55 * * * 1-6 *)

and

cron(0/10 * * * 1-6 *)

cron(5,15,25,35,45,55 * * * ? *) works, but WITH the days specified, either in this format or MON-SAT format, does not work and throws my serverless deploy

Upvotes: 1

Views: 384

Answers (2)

IftekharDani
IftekharDani

Reputation: 3729

every 10 min Mon-Sat

cron(0/10 * ? * MON-SAT *)

reference Link : https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html

Upvotes: 2

kenlukas
kenlukas

Reputation: 3973

This expression will work for you:

cron(5/10 * ? * Mon-Sat *)

The reason for the ? in the Day-of-Month field is because:

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.

In addition to run it "on the fives" use 5/10 because:

The / (forward slash) wildcard specifies increments. In the Minutes field, you could enter 1/10 to specify every tenth minute, starting from the first minute of the hour (for example, the 11th, 21st, and 31st minute, and so on). References

https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions

Upvotes: 0

Related Questions