Create a scheduled task

Updated at:
Copy as MD

Creates a scheduled task that triggers a scaling rule on a one-time or recurring schedule. Call the CreateScheduledTask API operation.

Prerequisites

Before you begin, ensure that you have:

  • An Alibaba Cloud account with a valid AccessKey pair for API authentication. For details on common request parameters such as AccessKeyId and Signature, see Common parameters.

  • A scaling group. Record the scaling group ID — for example, asg-bp18p2yfxow2dloq****.

  • A scaling rule in the scaling group. Record the Alibaba Cloud Resource Identifier (ARN) of the scaling rule — for example, ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****.

Request parameters

The following table describes the key parameters. For the full parameter list, see CreateScheduledTask.

Parameter

Type

Required

Description

Action

String

Yes

The API operation name. Set to CreateScheduledTask.

RegionId

String

Yes

The region of the scheduled task. Example: cn-qingdao.

LaunchTime

String

Yes

The time at which the scheduled task triggers. Use ISO 8601 format: YYYY-MM-DDThh:mmZ (UTC).

ScheduledAction

String

No

The ARN of the scaling rule to run when the task triggers. Example: ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****. Mutually exclusive with ScalingGroupId.

ScheduledTaskName

String

No

The name of the scheduled task. Example: scheduled****.

ScalingGroupId

String

No

The ID of the scaling group. If specified, you must also specify at least one of MinValue, MaxValue, or DesiredCapacity. Mutually exclusive with ScheduledAction.

RecurrenceType

String

No

The recurrence type. Valid values: Daily, Weekly, Monthly, Cron. Must be set together with RecurrenceValue. For Cron, specify a standard five-field cron expression: [Minute] [Hour] [Day_of_Month] [Month] [Day_of_Week]. Example: 30 6 2 runs the task every Tuesday at 06:30 UTC.

RecurrenceValue

String

No

The recurrence value. The format depends on RecurrenceType. Must be set together with RecurrenceType.

RecurrenceEndTime

String

No

The end time of the recurrence. Use ISO 8601 format: YYYY-MM-DDThh:mmZ (UTC).

You must specify either ScheduledAction or ScalingGroupId in the request. These two parameters are mutually exclusive.
The RecurrenceType and RecurrenceValue parameters must be set together. If you set one, you must set the other.

Sample request

The following example creates a scheduled task that triggers a scaling rule every day at 16:52 UTC, starting on 2014-08-17 and ending at 2014-08-17T16:55Z.

http(s)://ess.aliyuncs.com/?Action=CreateScheduledTask
&RegionId=cn-qingdao
&ScheduledTaskName=scheduled****
&ScheduledAction=ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****
&RecurrenceEndTime=2014-08-17T16:55Z
&LaunchTime=2014-08-17T16:52Z
&RecurrenceType=Daily
&RecurrenceValue=1
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&<Common request parameters>

Sample success responses

A successful response returns the ScheduledTaskId of the created task and a RequestId for troubleshooting.

XML format

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

<CreateScheduledTaskResponse>
    <ScheduledTaskId>edRtShc57WGXdt8TlPbr****</ScheduledTaskId>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</CreateScheduledTaskResponse>

JSON format

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

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

Related API operations

API

Description

CreateScheduledTask

Creates a scheduled task.

DescribeScheduledTasks

Queries scheduled tasks.

ModifyScheduledTask

Modifies a scheduled task.

DeleteScheduledTask

Deletes a scheduled task.