Search code examples
amazon-web-servicescronaws-event-bridge

Create an EventBridge cron for last day of the month in Monday to Friday


I have searched a lot for a solution on the EventBridge for Amazon so I can use a cron which trigger a lambda function on the last day of the month in working days MON-FRI.

I cannot accomplish the working days part but here it is the last day cron.

30 13 L * ? *

This code will be triggered on the last day of the month. The ? is for every day but in fact I want 0-4 or MON-FRI.

If I enter it in the amazon cron tab it make an error for invalid cron expression.

enter image description here


Solution

  • You can use this cron expression : 30 13 LW * ? *

    Cron expression

    Here the L wildcard in the Day-of-month fields specifies the last day of the month. And the W wildcard in the Day-of-month field specifies a weekday. So in the Day-of-month field, LW specifies the last weekday closest to the month.

    Ref: Schedule Expressions for Rules