This topic describes how to call the StopInstance operation by using Alibaba Cloud CLI to stop an ECS instance that is in the Running state.

Background information

You can call the StopInstance operation to stop an ECS instance in the Running state. After the call succeeds, the status of the ECS instance changes from Stopping to Stopped. We recommend that you read the description of the operation before you call the operation. For more information, see StopInstance.

When you call an API operation through Alibaba Cloud CLI, make sure that request parameter values of different data types are in required formats. For more information, see Parameter format overview.

Request examples

  1. Call the DescribeInstances operation to query the ID of the ECS instance that you want to stop.

    In this example, the instance name is used to query the ID of the instance.

    aliyun ecs DescribeInstances --RegionId cn-hangzhou --InstanceName namedemo --Status Running --output cols=Instances.Instance[].InstanceId
    Sample response:
  2. Stop the instance.

    In this example, the i-bp14a7xie8erwsvo**** pay-as-you-go instance is stopped. The instance is stopped after the pre-check and the Keep Stopped Instances and Continue Billing feature is enabled.

    aliyun ecs StopInstance --InstanceId i-bp14a7xie8erwsvo**** --ForceStop false --StoppedMode KeepCharging --DryRun false


        "RequestId": "A6344A79-D6CD-4AC2-8F2A-DEE3E16F8C5D"