After you create a Cloud Assistant command, you can run it on one or more Elastic Compute Service (ECS) instances. The execution status and results of the command on multiple instances do not affect each other.
Prerequisites
Before you run a Cloud Assistant command on ECS instances, make sure that the instances meet the following requirements:- The instances are in the Running (
Running
) state. - The Cloud Assistant Agent is installed on the instance. For more information, see Install the . To ensure that scheduled tasks can run as expected, make sure that the version of the Cloud Assistant Agent is not earlier than the following ones. A scheduled task can run a command at a specified interval, run a command only once at a specified time, or run a command based on a schedule defined by a cron expression with a specified year or time zone.
- Linux: 2.2.3.282
- Windows: 2.1.3.282
If the
ClientNeedUpgrade
error code is returned, update the Cloud Assistant Agent to the latest version. For information about how to update the Cloud Assistant Agent, see Upgrade or disable upgrades for the .
Background information
- You can call an API operation to run a command on up to 50 instances.
- If you select more than 50 instances to run a command in the ECS console, the system runs the command on the instances in batches.
Procedure in the ECS console
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- On the Commands tab of the Cloud Assistant page, find the command that you want to run and click Create Task in the Actions column.
- In the Create Task panel, configure parameters.
- Click Create Task.
Procedure by using the CLI
- Optional: Check the state of the instances on which you want to run a command. If the instances are not in the Running (
Running
) state, call the StartInstance operation to start the instances.aliyun ecs StartInstance --InstanceId 'i-bp1f4f6o8lv0wqof****'
Note Values enclosed in single quotation marks ('') are example values of the parameters. You must configure the parameters based on actual conditions.For more information, see StartInstance.
- Optional: Call the DescribeCloudAssistantStatus operation to check whether the Cloud Assistant Agent is installed on the instances.
aliyun ecs DescribeCloudAssistantStatus --RegionId 'cn-hangzhou' \ --InstanceId.1 'i-bp1f4f6o8lv0wqof****'
If the value ofCloudAssistantStatus
is true in the response, the Cloud Assistant Agent is installed on the instances. Otherwise, call the InstallCloudAssistant operation to install the Cloud Assistant Agent on the instances. For more information, see DescribeCloudAssistantStatus and InstallCloudAssistant. - Call the InvokeCommand operation to run a created Cloud Assistant command on one or more instances.
aliyun ecs InvokeCommand --RegionId 'cn-hangzhou' \ --InstanceId.1 'i-bp1f4f6o8lv0wqof****' \ --InstanceId.2 'i-bp137qu6142s3mhm****' \ --CommandId 'c-hz018qp243j****' \ --Timed 'false'
Parameter Example Description RegionId cn-hangzhou The region ID of the command. InstanceId.1 i-bp1f4f6o8lv0wqof**** The ID of the first instance on which to run the command. InstanceId.2 i-bp137qu6142s3mhm**** The ID of the second instance on which to run the command. CommandId c-hz018qp243j**** The ID of the command. Timed false Specifies whether to run the command on a schedule. To run the command on a schedule, set Timed to true and set Frequency to specify the schedule. You can configure a command to run at a fixed interval based on a rate expression, run only once at a specified time, or run at scheduled times based on a cron expression. For example, if you specify a cron expression of 0 */20 * * * ?, the command is run every 20 minutes. For more information, see Cron expressions.
For more information, see InvokeCommand.