All Products
Search
Document Center

Auto Scaling:CreateScheduledTask

Last Updated:Jun 24, 2024

Creates a scheduled task. A scheduled task is a type of scaling task that enables automatic execution of a specific scaling rule at a specified point in time. You can call the CreateScheduledTask operation to create a scheduled task to implement automatic scaling of computing resources. This ensures your business continuity and minimizes resource costs.

Operation description

  • If the scaling rule of a scheduled task fails to be executed due to an ongoing scaling activity in the scaling group or because the scaling group is disabled, the scheduled task is automatically retried during the time window specified by LaunchExpirationTime. If the scheduled task still fails after the specified time window ends, the task is automatically skipped.

  • If several scheduled tasks concurrently attempt to execute the same scaling rule within a scaling group, the following rules apply:

    • Scaling groups with Expected Number of Instances configured: The scaling activities incurred by the scheduled tasks are parallel scaling activities. In a proximate time window, Auto Scaling can trigger several scheduled tasks and then execute multiple parallel scaling activities at the same time.
    • Scaling groups with Expected Number of Instances not configured: The scaling activity incurred by the earliest scheduled task is executed. Considering that a scaling group allows for no more than one ongoing scaling activity simultaneously, other scheduled tasks will spontaneously invoke retries within the time window specified by LaunchExpirationTime. Upon completion of the first scheduled task, any retries invoked by other tasks within the time window specified by LaunchExpirationTime lead to continuous enforcement of the scaling rule, with each iteration generating a distinct scaling activity.
  • You can use one of the following methods to specify the scaling mode:

    • ScheduledAction: Specify an existing scaling rule that you want Auto Scaling to execute when the scheduled task is triggered.
    • ScalingGroupId: Specify the minimum number, maximum number, or expected number of instances for the scaling group for which you create the scheduled task.

    **

    Note You cannot specify ScheduledAction and ScalingGroupId at the same time.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the scheduled task.

cn-qingdao
ScheduledTaskNamestringNo

The name of the scheduled task. The name must be 2 to 64 characters in length, and can contain letters, digits, underscores (_), hyphens (-), and periods (.). The name must start with a letter or a digit. The name of the scheduled task must be unique in the region and within the Alibaba Cloud account.

If you do not specify this parameter, the value of the ScheduledTaskId parameter is used.

scheduled****
DescriptionstringNo

The description of the scheduled task. The description must be 2 to 200 characters in length.

Test scheduled task.
ScheduledActionstringNo

The scaling rule that you want to execute when the scheduled task is triggered. Specify the unique identifier of the scaling rule.

If you specify ScheduledAction, the scheduled task uses an existing scaling rule. You cannot specify ScheduledAction and ScalingGroupId at the same time.

ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****
RecurrenceEndTimestringNo

The end time of the scheduled task. Specify the time in the ISO 8601 standard in the YYYY-MM-DDThh:mmZ format.

The time must be in UTC. You cannot enter a point in time that is later than 365 days from the point in time at which the scheduled task is created.

2014-08-17T16:55Z
LaunchTimestringNo

The point in time at which the scheduled task is triggered. The time follows the ISO 8601 standard in the YYYY-MM-DDThh:mmZ format. The time must be in UTC. You cannot enter a point in time that is later than 90 days from the point in time at which the scheduled task is created.

  • If you specify the RecurrenceType parameter, the scheduled task is repeatedly executed at the point in time that is specified by the LaunchTime parameter.
  • If you do not specify the RecurrenceType parameter, the task is executed only once at the point in time that is specified by the LaunchTime parameter.
2014-08-17T16:52Z
RecurrenceTypestringNo

The interval at which the scheduled task is repeated. Valid values:

  • Daily: The scheduled task is executed once every specified number of days.
  • Weekly: The scheduled task is executed on each specified day of the week.
  • Monthly: The scheduled task is executed on each specified day of the month.
  • Cron: The scheduled task is executed based on the specified cron expression.

You must specify the RecurrenceType and RecurrenceValue parameters at the same time.

Daily
RecurrenceValuestringNo

The number of recurrences of the scheduled task.

  • If you set the RecurrenceType parameter to Daily, you can specify only one value for this parameter. Valid values: 1 to 31.
  • If you set the RecurrenceType parameter to Weekly, you can specify multiple values for this parameter. Separate the values with commas (,). The values that correspond to Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday are 0, 1, 2, 3, 4, 5, and 6.``
  • If you set the RecurrenceType parameter to Monthly, you can specify two values in the A-B format for this parameter. Valid values of A and B: 1 to 31. B must be greater than or equal to A.
  • If you set the RecurrenceType parameter to Cron, you can specify a cron expression. A cron expression is written in UTC time and consists of the following fields: minute, hour, day, month, and week. The expression can contain the letters L and W and the following wildcard characters: commas (,), question marks (?), hyphens (-), asterisks (*), number signs (#), and forward slashes (/).

You must specify both the RecurrenceType parameter and the RecurrenceValue parameter.

1
TaskEnabledbooleanNo

Specifies whether to enable the scheduled task.

  • true
  • false

Default value: true.

true
LaunchExpirationTimeintegerNo

The time period during which the failed scheduled task can be retried. Unit: seconds. Valid values: 0 to 1800.

Default value: 600.

600
MinValueintegerNo

The minimum number of instances in the scaling group if you specify the ScalingGroupId parameter.

0
MaxValueintegerNo

The maximum number of instances in the scaling group if you specify the ScalingGroupId parameter.

10
DesiredCapacityintegerNo

The expected number of instances in the scaling group if you specify the ScalingGroupId parameter.

Note You must specify the DesiredCapacity parameter when you create a scaling group.
10
ScalingGroupIdstringNo

The ID of the scaling group. If you specify this parameter, the number of instances in the scaling group will be changed when the scheduled task is triggered.

If you specify ScalingGroupId, you must also specify at least one of the following parameters: MinValue, MaxValue, and DesiredCapacity. You cannot specify ScheduledAction and ScalingGroupId at the same time.

asg-bp18p2yfxow2dloq****

Response parameters

ParameterTypeDescriptionExample
object
ScheduledTaskIdstring

The globally unique ID of the scheduled task. The globally unique ID is generated by the system.

edRtShc57WGXdt8TlPbr****
RequestIdstring

The ID of the request.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

Examples

Sample success responses

JSONformat

{
  "ScheduledTaskId": "edRtShc57WGXdt8TlPbr****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history