Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I schedule an AWS Lambda cron to run at 11:30pm on the last day of the month?

I'd like my Lambda function to run on the last day of every month at 11:30pm.

I'm using the Serverless Framework so all I need is the right Schedule Expression (docs here & info here)

Any help greatly appreciated.

NB: Unfortunately I can't just do it at the start of the month as there's a dependency on pulling data from a 3rd party tool that only calculates data for 'this month'.

like image 938
Bryce York Avatar asked Jan 30 '17 08:01

Bryce York


People also ask

What timezone does AWS cron use?

All scheduled events use UTC time zone and the minimum precision for schedules is 1 minute. CloudWatch Events supports cron expressions and rate expressions.

How do you trigger Lambda automatically?

Setup Cloudwatch Event Rule You can either trigger the lambda function for the fixed rate of 'n' minutes. Next, we have to add the Lambda function as a Target to this Event Rule. Under Targets, Click Add target, In the drop-down menu, choose the Lambda function, For Function, Choose the function name.


1 Answers

From docs:

  • The L wildcard in the Day-of-month or Day-of-week fields specifies the last day of the month or week.

So, try this cron expression for 11:30 PM at the last day of the month:

cron(30 23 L * ? *)
like image 139
Zanon Avatar answered Oct 06 '22 01:10

Zanon