This topic describes how to call the StopInstance operation by using Alibaba Cloud command-line interface (CLI) to stop an ECS instance 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 state of the ECS instance changes from Stopping to Stopped. 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, query the ID of an ECS instance by using its name.

    aliyun ecs DescribeInstances --RegionId cn-hangzhou --InstanceName namedemo --Status Running --output cols=Instances.Instance[].InstanceId
    Sample response:
  2. Stop an ECS instance that is in the running state.

    In this example, stop ECS instance i-bp14a7xie8erwsvo**** that is in the running state and uses the pay-as-you-go billing method. This instance is stopped after the pre-check and still charged after it is stopped.

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


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