简体   繁体   English

如何使用Windows命令行停止EC2实例?

[英]how to stop EC2 instances with windows command line?

I tried to do the following: 我试着做以下事情:

  1. Download: client EC2 in https://aws.amazon.com/developertools/351 . 下载: https ://aws.amazon.com/developertools/351中的客户端EC2。 And save that in C:/AWS/CLI. 并将其保存在C:/ AWS / CLI中。

  2. Create in the environment variables, a new system variable. 在环境变量中创建一个新的系统变量。

    • Name: JAVA_HOME 名称: JAVA_HOME
    • Value: C:\\Program Files\\Java\\jre7 值: C:\\Program Files\\Java\\jre7
  3. Create other new system variable. 创建其他新的系统变量。

    • Name: EC2_HOME 名称: EC2_HOME
    • Value: C:\\AWS\\CLI 值: C:\\AWS\\CLI
  4. Edit the value of the system variable Path , and add %EC2_HOME%\\bin . 编辑系统变量Path的值,并添加%EC2_HOME%\\bin

  5. Create other two system variables: 创建其他两个系统变量:

    • System variable name: AWS_ACCESS_KEY , value: my access key. 系统变量名称: AWS_ACCESS_KEY ,值:我的访问密钥。
    • System variable name: AWS_SECRET_KEY , value: my secret key. 系统变量名称: AWS_SECRET_KEY ,值:我的密钥。
  6. Open my windows command line and execute the code: 打开我的Windows命令行并执行代码:

     ec2-stop-instances <id_instancia> –region <region> 

I received the error: 我收到了错误:

the filename, directory name or volume label syntax is incorrect.

Why does this happen? 为什么会这样?

Those API tools look somewhat old. 这些API工具看起来有些陈旧。

These days, it is recommended to use either: 目前,建议使用以下两种方法之一:

If you like PowerShell, use that one. 如果您喜欢PowerShell,请使用它。 Otherwise, go for the AWS CLI. 否则,请转到AWS CLI。 There is good documentation for both. 两者都有很好的文档。

There's an extremely easy way to stop the instance from the instance's cmd, that is 有一种非常简单的方法可以从实例的cmd中停止实例,也就是说

shutdown /s

That will shutdown (and stop, not terminate) the EC2 这将关闭(并停止,不终止)EC2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM