This topic describes how to create a scheduled task to scale computing resources in response to predictable business changes in the future. Scheduled tasks enable the system to automatically obtain sufficient computing resources before business peaks and release idle computing resources after the peaks.
A scheduled task is preconfigured to execute a specified scaling rule at a specified time in the future. When the specified time arrives, the scheduled task automatically scales computing resources. This allows you to reduce costs while meeting business requirements. You can also specify the recurrence for scheduled tasks if business changes are regular.
You can set the interval at which a scheduled task is automatically retried to ensure the timely execution of the scheduled task. If multiple scheduled tasks are to be executed in one minute, Auto Scaling executes the scheduled task that is created most recently.
- Log on to the Auto Scaling console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Click Create Scheduled Task.
- In the dialog box that appears, set parameters for the scheduled task.
- Enter a task name.The name must be 2 to 64 characters in length. It must start with a letter or a digit. It can contain periods (.), underscores (_), and hyphens (-).
- Optional:Enter a description.You can enter the details about the scheduled task, such as its purpose and function.
- Set the time to execute the scheduled task.The scheduled task will be triggered when the specified time arrives.
- Select a scaling group.
- Configure the scaling method.
- Select an existing rule: specifies an existing scaling rule in the scaling group. The scaling rule is executed
when the scheduled task is triggered.
Note Scheduled tasks can execute only simple scaling rules.
- Configure the number of instances in a scaling group: specifies the minimum, maximum, and expected numbers of instances in the scaling
group. When the scheduled task is triggered, its settings will overwrite that of the
Note If the Expected Instances feature is disabled for a scaling group during creation, you can specify only the minimum and maximum numbers of instances in the scaling group.
- Select an existing rule: specifies an existing scaling rule in the scaling group. The scaling rule is executed when the scheduled task is triggered.
- Optional:Set the retry expiration time.The value ranges from 0 to 21600, in seconds. If a scaling activity fails to be executed at the specified time, Auto Scaling will execute the scheduled task again within the retry expiration time.
- Optional:Set the recurrence period.You can configure the scheduled task to be repeatedly executed on a daily, weekly, or monthly basis. You can also use a cron expression to specify complex recurrence settings. For more information, see Cron expressions.
- Enter a task name.
- Click OK.
Cron expressions use the UTC+0 time zone. Add eight hours when you convert the time to the local system time in China. Additionally, the time when a cron expression is first executed must be earlier than the end time of the recurrence that you set for the scheduled task. Otherwise, the scheduled task will fail to be created.
A cron expression is a string separated with spaces. It is divided into five to seven fields. Currently, scheduled tasks in Auto Scaling support cron expressions with five fields, including minute, hour, day, month, and week. The following table describes the value range of each field.
|Week||Yes||0‒7. The value for Sunday is 7.|
- Specifies multiple values by separating them with commas (,). Example: 1,3,4,7,8.
- Specifies the range of values by using a hyphen (-). For example, 1-6 is equivalent to 1,2,3,4,5,6.
- Specifies any possible values by using an asterisk (*). For example, you can enter an asterisk in the hour field to represent each hour, which is equivalent to 0-23.
- Specifies the frequency by using a forward slash (/). For example, 0-23/2 in the hour field indicates that the task is executed every two hours. Forward slashes (/) can be used with asterisks (*). For example, */3 in the hour field indicates that the task is executed every three hours.