All Products
Search
Document Center

Auto Scaling:Overview

Last Updated:Feb 20, 2024

A scheduled task allows you to specify a specific point of time to execute a scaling rule. You can create scheduled tasks to enable automatic scaling of computing resources. In this case, you can run your business as expected while minimizing resource costs.

Configuration items

The following table describes the configuration items of a scheduled task.

Item

Description

Executed At

The time at which the scheduled task is executed.

  • If no value is specified for the Recurrence parameter, the scheduled task is executed only once at the time specified by the Executed At parameter.

  • If a value is specified for the Recurrence parameter, the scheduled task is executed once at the time specified by the Executed At parameter and is repeatedly executed based on the cycle specified by the Recurrence parameter.

Important

Do not specify a time later than 90 days from the date on which the scheduled task is created or modified. Otherwise, the scheduled task cannot take effect.

Scaling Group

The scaling group for which the scheduled task is created. Select an existing scaling group. For more information, see Overview.

Scaling Method

  • Select Existing Scaling Rule: You can select an existing scaling rule. Scheduled tasks support simple scaling rules. For more information, see Overview.

  • Configure Number of Instances in Scaling Group: You can specify a maximum number, a minimum number, or an expected number of instances in the scheduled task. The new numbers overwrite the numbers that are specified when you create the scaling group. The new numbers take effect only at the specified time.

    Note
    • If no value was specified for the Expected Number of Instances parameter when you created the selected scaling group, you can configure only the Maximum Instances and Minimum Instances parameters when you create the scheduled task.

    • If a value was specified for the Expected Number of Instances parameter when you created the selected scaling group, you must configure the Maximum Instances, Minimum Instances, and Expected Instances parameters at the same time. Otherwise, the scaling requests initiated by the scheduled task will be rejected.

Simple Scaling Rule

This parameter is available only if you set the Scaling Method parameter to Select Existing Scaling Rule. Select an existing simple scaling rule. For more information, see Manage scaling rules or CreateScalingRule.

Retry Interval (Seconds)

The interval at which a scheduled task is retried if the scheduled task fails to be executed. This prevents the execution of the scheduled task from being affected by the single execution failure of the selected scaling rule. If multiple scheduled tasks need to be executed within the same minute, Auto Scaling executes the most recently created scheduled task.

Recurrence

The cycle during which the scheduled task is repeatedly executed. You can set the Recurrence parameter to Not Set, By Day, By Week, or By Month. If you have complex business requirements, you can also set the Recurrence parameter to Cron Expression. For information about the cron expressions, see Cron expressions in this topic.

Note

After you create the scheduled task, you cannot change the setting of the Recurrence parameter to Not Set.

Cron expressions

When you create a scheduled task in the Auto Scaling console, you can set the Recurrence parameter to Cron Expression.

A cron expression is a string that represents a schedule. The string consists of multiple fields that are separated by spaces and describe individual details of the schedule. Auto Scaling supports cron expressions that consist of five fields in the X X X X X format. X is a placeholder for a field. Each field in a cron expression represents minutes, hours, day of month, month, and day of week in sequence. Each field can be a definite value or a special character that has a logical meaning.

When you configure a cron expression for a scheduled task, take note of the following items:

  • Cron expressions are in UTC+0. When you configure a cron expression, you must convert the local time to UTC+0. For example, the time in China is in UTC+8. If you are in China and you want to execute your scheduled task at 20:00:00 every day, you must subtract 8 hours from 20:00:00. In this case, you must set the cron expression to 0 12 * * ?.

  • A scheduled task that has a specified cron expression can be executed only once every five minutes.

  • The time at which a scheduled task that has a specified cron expression is first executed must be earlier than the time at which the cycle specified by the Recurrence parameter for the scheduled task to be executed expires. Otherwise, an error is reported.

Table 1. Field values

Field

Required

Value range

Special character

Minute

Yes

0 to 59

, - / *

Hour

Yes

0 to 23

, - / *

Day

Yes

1 to 31

, - / * ? L W

Month

Yes

1 to 12

, - / *

Week

Yes

1 to 7. The value for Sunday is 7.

, - * ? / L #

Table 2 Special characters

Special character

Description

Example

*

All valid field values

In the Month field, an asterisk (*) indicates every month. In the Week field, an asterisk (*) indicates every day of the week.

,

Enumerated values

In the Minute field, 5,20 indicates the fifth minute and the twentieth minute.

-

Range values

In the Minute field, 5-20 indicates the range from the 5th to 20th minute.

/

Increments

In the Minute field, 0/15 indicates every 15 minutes starting from the zeroth minute. 3/20 indicates every 20 minutes from the third minute.

?

Unspecified. Only the Day and Week fields support this character.

Note

To prevent calculation conflicts after you specify the Day field or Week field, you must specify a question mark (?) in the unspecified field.

In the Day field, ? indicates that no specific day of the month is specified. In the Week field, ? specifies that no specific day of the week is specified. For example, 15 10 15 * ? in UTC+0 specifies that the scheduled task is executed at 10:15:00 on the 15th day of each month, regardless of the day of the week.

L

L, the first letter of Last, specifies the last day of a specific period. Only the Day and Week fields support this character.

Note

To prevent logic errors, do not specify a list or range when you use the L character.

  • In the Day field, L specifies the last day of a month. In the Week field, L specifies the last day of a week.

  • L can be preceded by a value. For example, 6L in the Week field specifies the last Saturday of a month.

W

The weekday that is nearest to the specified day of the month. The weekday that the W character indicates is in the same month as the specified day of the month. LW indicates the last weekday of the specified month.

If 5W is specified in the Day field and the fifth day of the month is a Saturday, the task is triggered on the nearest weekday which is Friday, the fourth day of the month. If the fifth day of the month is a Sunday, the scheduled task is triggered on the nearest weekday which is Monday, the sixth day of the month. If the fifth day of the month is a weekday, the scheduled task is triggered on the 5th day of the month.

#

A specific day of a specific week in every month. Only the Week field supports this character. Valid values: 1 to 5.

In the Week field, 4#2 indicates the second Thursday of a month.

Table 4 Examples

The following table provides examples of cron expressions in UTC+0. These cron expressions have different meanings. When you configure a cron expression, you must convert the local time into UTC+0.

Example

Description

15 10 ? * *

Executes the scheduled task at 10:15:00 every day.

15 9 * * *

Executes the scheduled task at 9:15:00 every day.

0 12 * * ?

Executes the scheduled task at 12:00:00 every day.

0 10,14,16 * * ?

Executes the scheduled task at 10:00:00, 14:00:00, and 16:00:00 every day.

15 10 15 * ?

Executes the scheduled task at 10:15:00 on the 15th day of every month.

15 10 L * ?

Executes the scheduled task at 10:15:00 on the last day of every month.

15 10 ? * 6L

Executes the scheduled task at 10:15:00 on the last Saturday of every month.

15 10 ? * 6#3

Executes the scheduled task at 10:15:00 on the third Saturday of every month.

Create a scheduled task

The following table provides links about how to manage a scheduled task.

User guide

Operation

API reference

Create scheduled tasks

Create a scheduled task

CreateScheduledTask

Modify a scheduled task

ModifyScheduledTask

Enable a scheduled task

N/A

Disable a scheduled task

N/A

Delete a scheduled task

DeleteScheduledTask

Note

After you create a scheduled task, you can call the DescribeScheduledTasks API operation to query the details of the scheduled task.