阿里云的停机不收费还是可以省一点点的,结合[腾讯云的域名自动解析接口](http://www.yuanchengzhushou.cn/article/7923.html),也可以方便的实现域名动态的绑定到自己的按需使用服务器
但是每次都要手工的开机关机,着实有点麻烦
那么有没有相关的api接口呢
>root@localhost$ cat shutdown.py
\#!/usr/bin/env python
\#coding=utf-8
from aliyunsdkcore import client
from aliyunsdkecs.request.v20140526 import StopInstanceRequest
list1 = ['自己的实例id']
clt = client.AcsClient('自己的secretid','自己的secretkey','cn-hangzhou')
for i in list1:
shutdown = StopInstanceRequest.StopInstanceRequest()
shutdown.set_InstanceId(i)
shutdown.set_StoppedMode('StopCharging')
action = clt.do_action_with_exception(shutdown)
print "现在停机:" + i
print action
即可实现,再也不用手工的开机与关机了
需要下载阿里云的` aliyun-python-sdk-core aliyun-python-sdk-ecs`
`yum install -y python-pip`
cd aliyun-python-sdk-core
执行`python setup.py install`
cd aliyun-python-sdk-ecs
执行`python setup.py install`
执行 `python2.7 shutdown.py`