[英]Is it possible to set up Amazon EC2 auto-scaling for particular days of the week?
I need to have a different auto-scaling policy for weekdays vs weekend. 在工作日和周末,我需要采用其他自动缩放策略。
So far I figured out how to set up the same policy for every day. 到目前为止,我已经弄清楚了如何每天设置相同的策略。 The cmd call and the CRON string look like that: cmd调用和CRON字符串如下所示:
as-put-scheduled-update-group-action TNUPWN --auto-scaling-group TNASG --region us-west-2 --recurrence "30 18 * * *" --desired-capacity 1
But when I try to set a CRON string for week days only eg 但是当我尝试仅在工作日设置CRON字符串时,例如
30 7 ? * MON-FRI *
or
0 30 7 ? * MON-FRI *
I am getting the error 我收到错误
as-put-scheduled-update-group-action: Malformed input-Given recurrence string:30 1 ? * MON-FRI * is
invalid
Usage:
as-put-scheduled-update-group-action
ScheduledActionName --auto-scaling-group value [--desired-capacity
value ] [--end-time value ] [--max-size value ] [--min-size value ]
[--recurrence value ] [--start-time value ] [--time value ]
[General Options]
Any ideas? 有任何想法吗? Is it even possible with AWS? AWS甚至有可能吗?
The problem is that AWS only supports the 5 digit notation as opposed to the 6 digit notation in your example. 问题在于,AWS仅支持5位数字表示法,而不是示例中的6位数字表示法。
The AWS official blog announcement links directly to the Wikipedia page for cron which has the 5 digit notation at the top. AWS官方博客公告直接链接到cron的Wikipedia 页面,顶部有5位符号。
Your schedule corrected: 您的时间表已更正:
I think the problem is with your cron string. 我认为问题出在您的cron字符串上。 Try using digits (instead of day abbreviations). 尝试使用数字(而不是天的缩写)。
Also, you could implement it this way: 另外,您可以通过以下方式实现它:
Setup scheduled group action for every Friday at midnight to increase capacity. 在每个星期五的午夜设置排定的小组动作,以增加容量。
--recurrence 0 0 * * 5 * --recurrence 0 0 * * 5 *
Setup scheduled group action for every Sunday at midnight to reduce capacity. 在每个星期日的午夜设置排定的小组动作,以减少容量。
--recurrence 0 0 * * 7 * --recurrence 0 0 * * 7 *
This article has some sample commands with properly formatted cron strings: 本文提供了一些带有正确格式的cron字符串的示例命令:
http://www.newvem.com/how-to-configure-aws-cloud-auto-scaling-to-scale-based-on-a-schedule/ http://www.newvem.com/how-to-configure-aws-cloud-auto-scaling-to-scale-based-on-a-schedule/
And here is a cron format reference: 以下是cron格式参考:
http://www.nncron.ru/help/EN/working/cron-format.htm http://www.nncron.ru/help/EN/working/cron-format.htm
If it helps anyone else, I had the following Cron strings rejected: 如果对其他人有帮助,则拒绝以下Cron字符串:
0 0 1 1/1 * ? TUE-SAT
0 0 1 1/1 * ? Tue-Sat
0 0 1 * * ? Tue-Sat
0 1 ? * TUE-SAT
All of these had been found valid by this online utility: http://cronexpressiondescriptor.azurewebsites.net 所有这些都已通过此在线实用程序发现有效: http : //cronexpressiondescriptor.azurewebsites.net
Finally, it worked with this one: 最后,它与这一工作:
0 1 * * TUE-SAT
So AWS must have their own particular syntax. 因此,AWS必须具有自己的特定语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.