英文:
Cron expression to run on first Tuesday of the month, Tuesday should be followed by a Monday
问题
我想安排一个 Lambda 函数,在每个月的第一个星期二运行。但是星期二应该紧跟在星期一后面。
例如:
8月1日:星期二 -> 不应调用 Lambda
8月7日:星期一,8月8日:星期二 -> 应调用 Lambda
我无法找到相应的 cron 表达式。
任何提示都会有帮助!
英文:
I want to schedule a lambda function to run on first Tuesday every month. But the Tuesday should be followed by Monday.
Ex:
Aug 1: Tuesday -> Lambda shouldn't get invoked
Aug 7: Monday, Aug 8: Tuesday -> Lambda should be invoked
I am not able to figure out the cron expression for the same.
Any leads would be helpful!
答案1
得分: 1
为简化问题,您可以说您需要在每个月的第一个星期一之后执行 Lambda 函数。
一种选项是在每月的第一个星期一的最后一分钟执行 Lambda。
cron(59 23 ? * 2#1 *)
此外,如果您使用 AWS 事件桥调度,还有灵活的时间窗口。
如果这对您不起作用,将需要创建一个 Lambda 来处理这个逻辑,因为 AWS cron 表达式不支持此逻辑。
英文:
To simplify your problem you can say that you need to execute the lambda the day after the first monday of the month, every month.
one option would be to execute the Lambda on the last minute of the first monday of the month.
cron(59 23 ? * 2#1 *)
Also if you use AWS event bridge schedules there is a flexible time windows.
If this doesn't work for you, it will be necessary to create a lambda to handle this logic, the AWS cron expression does not support this logic out of the box.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论