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.
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 |
|
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.
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 # |
Special character | Description | Example |
| All valid field values | In the Month field, an asterisk ( |
| 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, |
| 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 Day field, |
| 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 |
|
| The weekday that is nearest to the specified day of the month. The weekday that the | If |
| 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, |
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 |
| Executes the scheduled task at 10:15:00 every day. |
| Executes the scheduled task at 9:15:00 every day. |
| Executes the scheduled task at 12:00:00 every day. |
| Executes the scheduled task at 10:00:00, 14:00:00, and 16:00:00 every day. |
| Executes the scheduled task at 10:15:00 on the 15th day of every month. |
| Executes the scheduled task at 10:15:00 on the last day of every month. |
| Executes the scheduled task at 10:15:00 on the last Saturday of every month. |
| 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 a scheduled task | ||
Modify a scheduled task | ||
Enable a scheduled task | N/A | |
Disable a scheduled task | N/A | |
Delete a scheduled task |
After you create a scheduled task, you can call the DescribeScheduledTasks API operation to query the details of the scheduled task.