All Products
Search
Document Center

Auto Scaling:ModifyScheduledTask

更新時間:Jul 09, 2024

Modifies a scheduled task. If an existing scheduled task cannot meet your business requirements anymore, you can call the ModifyScheduledTask operation to modify the task attributes such as the scaling rule to execute, the recurrence of the scheduled task, and the retry policy, without the need to create a new task.

Usage notes

Scheduled tasks support the following scaling methods:

  • 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 to which the scheduled task belongs.

Note

You cannot specify both ScheduledAction and ScalingGroupId.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

ModifyScheduledTask

The operation that you want to perform. Set the value to ModifyScheduledTask.

ScheduledTaskId

String

Yes

edRtShc57WGXdt8TlPbr****

The ID of the scheduled task.

ScheduledTaskName

String

No

scheduled****

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

Description

String

No

Test scheduled task.

The description of the scheduled task. The description can be 1 to 200 characters in length.

ScheduledAction

String

No

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

The ID of the scaling group that Auto Scaling executes when the scheduled task is triggered. You can obtain the ID of a scaling rule on the scaling rule details page. This parameter is available only if you specify ScheduledAction.

Note

If you specify ScheduledAction, you cannot specify ScalingGroupId.

RecurrenceEndTime

String

No

2014-08-20T16:55Z

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 specify a point in time that is later than 365 days from the point in time at which the scheduled task is modified.

LaunchTime

String

No

2014-08-18T10:52Z

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

  • If you specify RecurrenceType, the scheduled task is repeatedly executed at the point in time that is specified by LaunchTime.

  • If you do not specify RecurrenceType, the scheduled task is executed only once at the time point that is specified by LaunchTime.

RecurrenceType

String

No

Daily

The type of the recurring execution cycle of the scheduled task. The scheduled task can be executed by day, week, or month. Valid values:

  • Daily: The scheduled task is repeatedly executed every specified number of days.

  • Weekly: The scheduled task is executed on each specified day of a week.

  • Monthly: The scheduled task is executed on each specified day of a month.

  • Cron: The scheduled task is executed based on the specified cron expression.

Make sure that the values that you specify for RecurrenceType and RecurrenceValue must be valid at the same time after you modify the scheduled task.

RecurrenceValue

String

No

2

The numerical value that corresponds to the recurring execution cycle of the scheduled task.

  • If you set RecurrenceType to Daily, you can specify only one value for this parameter. Valid values: 1 to 31.

  • If you set RecurrenceType to Weekly, you can specify multiple values for this parameter. Separate the values with commas (,). For example, 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 RecurrenceType to Monthly, you can specify two values in the A-B format. Valid values of A and B: 1 to 31. B must be greater than or equal to A.

  • If you set RecurrenceType 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 (/).

Make sure that the values that you specify for RecurrenceType and RecurrenceValue must be valid at the same time after you modify the scheduled task.

TaskEnabled

Boolean

No

true

Specifies whether the scheduled task is enabled. Valid values:

  • true

  • false

Default value: true.

LaunchExpirationTime

Integer

No

600

The duration within which Auto Scaling can retry the execution of the scheduled task in case of failures. Unit: seconds. Valid values: 0 to 1800.

Default value: 600.

MinValue

Integer

No

0

The minimum number of instances that must be maintained in the scaling group. This parameter is available only if you specify ScalingGroupId.

MaxValue

Integer

No

10

The maximum number of instances that can be contained in the scaling group. This parameter is available only if you specify ScalingGroupId.

DesiredCapacity

Integer

No

10

The expected number of instances in the scaling group. This parameter is available only if you specify ScalingGroupId.

Note

This parameter takes effect only if you specify DesiredCapacity when you create the scaling group.

ScalingGroupId

String

No

asg-bp18p2yfxow2dloq****

The ID of the scaling group whose scheduled task that you want to modify. If you specify ScalingGroupId, you must also specify one of the following parameters: MinValue, MaxValue, and DesiredCapacity.

Note

If you specify ScalingGroupId, you cannot specify ScheduledAction.

RegionId

String

No

cn-hangzhou

The region ID of the scaling group.

Response parameters

Parameter

Type

Example

Description

RequestId

String

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

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=ModifyScheduledTask
&ScheduledTaskId=edRtShc57WGXdt8TlPbr****
&ScheduledTaskName=scheduled****
&Description=Test scheduled task.
&ScheduledAction=ari:acs:ess:cn-hangzhou:14069264****:scalingrule/asr-bp12tcnol686y1ik****
&RecurrenceEndTime=2014-08-20T16:55Z
&LaunchTime=2014-08-18T10:52Z
&RecurrenceType=Daily
&RecurrenceValue=2
&TaskEnabled=true
&LaunchExpirationTime=600
&MinValue=0
&MaxValue=10
&DesiredCapacity=10
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ModifyScheduledTaskResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</ModifyScheduledTaskResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

404

InvalidScheduledTaskId.NotFound

The specified scheduled task does not exist.

The specified scheduled task does not exist within the Alibaba Cloud account.

400

InvalidScheduledTaskName.Duplicate

The specified value of parameter

ScheduledTaskName

is duplicated.

A scheduled task with the given name already exists.

400

ScheduledAction.RegionMismatch

The specified scheduled task and the specified scheduled action are not in the same Region.

The specified scaling rule and the specified scheduled task are located in different regions.