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.

Background information

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.

Note You can create only a limited number of scheduled tasks under an Alibaba Cloud account. For more information, see Limits.

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.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, choose Scaling Tasks > Scheduled Tasks.
  3. In the top navigation bar, select a region.
  4. Click Create Scheduled Task.
  5. In the dialog box that appears, set parameters for the scheduled task.
    1. 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 (-).
    2. Optional:Enter a description.
      You can enter the details about the scheduled task, such as its purpose and function.
    3. Set the time to execute the scheduled task.
      The scheduled task will be triggered when the specified time arrives.
    4. Select a scaling group.
    5. 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 scaling group.
        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.
    6. 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.
    7. 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.
  6. Click OK.

Cron expressions

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.

Field Required Value range
Minute Yes 0‒59
Hour Yes 0‒23
Day Yes 1‒31
Month Yes 1‒12
Week Yes 0‒7. The value for Sunday is 7.
You can enter multiple values in a field by using the following methods:
  • 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.