A scheduled task executes a scaling rule at a specific time to automatically scale computing resources. This helps you adapt to predictable changes in demand while optimizing costs.
Configuration options
The following table describes the main configuration options for a scheduled task.
|
Parameter |
Description |
|
Executed At |
The time when the scheduled task runs.
Important
The execution time must be within 90 days of the task's creation or modification date. |
|
Scaling Group |
The scaling group that the scheduled task applies to. Select an existing scaling group. For more information, see Overview of scaling groups. |
|
Scaling Method |
|
|
Simple Scaling Rule |
This option appears only if Select Existing Scaling Rule is set to Select Existing Scaling Rule. Select an existing simple scaling rule. For more information, see Configure scaling rules or CreateScalingRule. |
|
Retry Interval (Seconds) |
The retry interval for a failed scheduled task. Retries prevent a single scaling failure from blocking the task. |
|
Recurrence |
The recurrence pattern for the task. Options include no recurrence (run once), daily, weekly, monthly, or a cron expression for more complex schedules. For more information, see Cron expressions. Note
When you modify a scheduled task, you cannot change its recurrence method to Not Set. |
Cron expressions
In the Auto Scaling console, use a cron expression to define a scheduled task's Recurrence.
A cron expression uses five space-separated fields in the format X X X X X, where X represents a field value. The fields are, in order: minute, hour, day of month, month, and day of week. Each field accepts a specific value or a special character.
Keep the following points in mind when configuring a cron expression:
-
Cron expressions use the UTC+0 time zone. You must convert your local time to UTC+0. For example, to run a task at 20:00 China Standard Time (UTC+8), subtract 8 hours and set the cron expression to
0 12 * * ?. -
A single cron-based scheduled task can run at most once every five minutes.
-
Ensure that the first execution time of the cron expression is earlier than the end time of the recurrence. Otherwise, a parameter error occurs.
|
Field |
Required |
Valid values |
Special characters |
|
Minute |
Yes |
0-59 |
, - / * |
|
Hour |
Yes |
0-23 |
, - / * |
|
Day of month |
Yes |
1-31 |
, - / * ? L W |
|
Month |
Yes |
1-12 |
, - / * |
|
Day of week |
Yes |
1-7, where 1 represents Sunday. |
, - * ? / L # |
|
Special character |
Description |
Example |
|
|
Includes all valid values in a field. |
In the month field, |
|
|
Separates items in a list of values. |
In the minute field, |
|
|
Specifies a range of values. |
In the minute field, |
|
|
Specifies increments. |
In the minute field, |
|
|
Indicates no specific value. This character is supported only in the day-of-month and day-of-week fields. Note
When you specify a value for either the day-of-month or day-of-week field, you must use a |
In the day-of-month field, |
|
|
An abbreviation for "last". This character is supported only in the day-of-month and day-of-week fields. Note
When using the |
|
|
|
An abbreviation for "weekday". The task runs on the nearest weekday to the specified day. The |
If you specify |
|
|
Specifies the Nth day of the week in a month. This character is supported only in the day-of-week field. Valid values: 1 to 5. |
In the day-of-week field, |
Table 4. Examples (UTC+0)
The following table provides examples for the UTC+0 time zone. When you set a cron expression, you must convert your local time to UTC+0.
|
Cron expression |
Description |
|
|
Executes the task at 10:15 every day. |
|
|
Executes the task at 09:15 every day. |
|
|
Executes the task at 12:00 every day. |
|
|
Executes the task at 10:00, 14:00, and 16:00 every day. |
|
|
Executes the task at 10:15 on the 15th of every month. |
|
|
Executes the task at 10:15 on the last day of every month. |
|
|
Executes the task at 10:15 on the last Friday of every month. |
|
|
Executes the task at 10:15 on the third Friday of every month. |
Configure a scheduled task
The following table lists resources for managing scheduled tasks.
|
Console documentation |
Actions |
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 |
You can also call the DescribeScheduledTasks operation to query scheduled task details.