2 Answers
- Newest
- Most votes
- Most comments
0
Hello.
I think it would work with the following cron.
https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html
cron(30 6 ? * MON-FRI *)
0
Have you considered using an Auto Scaling group with a scheduled scaling policy for this? One additional benefit to this approach would be the EC2 instance health check and automated replacement if an instance becomes unhealthy during your "in service" period. More details on using a scheduled scaling policy with Auto Scaling groups can be found here: https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scheduled-scaling.html
answered 2 years ago
Relevant content
- asked 2 years ago
- asked 3 years ago
- asked 2 years ago
- asked 4 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 years ago
Hi. Thank you for you answer. Unfortunately that also gets flagged as invalid. The exact error is: InvalidSchedule: Schedule expression cron(30 6 ? * MON-FRI *) is currently not accepted. Supported expressions are every half, 1, 2, 4, 8 or 12 hour(s), every specified day and time of the week, or a specific day in a specific week of the month Supported examples are: cron(0 0/30 * 1/1 * ? *), cron(0 0 0/4 1/1 * ? *), cron (0 0 10 ? * SUN *), cron (0 0 10 ? * * *), cron(0 0 ? * TUE#2 *)
Systems manager. I am using state manager to spin up and shut down EC2 instances.
Thank you for your reply. By the way, which service do you set up cron for? The above cron is not available when used with Systems Manager State Manager. As described in the following document, you should only be able to configure cron to run at specific times. https://docs.aws.amazon.com/systems-manager/latest/userguide/reference-cron-and-rate-expressions.html#reference-cron-and-rate-expressions-association
Ok. I see. What do you mean by service? I am using it to start and stop EC2 instances at set times and days of the week.
Sorry, my comments were misplaced.
For such use cases, it may be possible to use the EventBridge scheduler. EventBridge scheduler supports many APIs and allows flexible cron settings. https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduler.html