amazon-web-services - 通过 Lambda 重新启动服务器后 AWS Win 任务未运行
问题描述
我编写了一个简单的任务计划来关闭 AWS Windows 服务器和一个简单的 Lambda 代码来打开停止的实例,请参阅代码:
import time
import json
import boto3
def lambda_handler(event, context):
# boto3 client
client = boto3.client('ec2')
ssm = boto3.client('ssm')
# getting instance information
describeInstance = client.describe_instances()
#print("eddie", describeInstance["Reservations"][0]["Instances"][0]["State"]["Name"])
InstanceId = []
# fetchin instance id of the running instances
for i in describeInstance['Reservations']:
for instance in i['Instances']:
if instance["State"]["Name"] == "stopped":
InstanceId.append(instance['InstanceId'])
client.start_instances(InstanceIds=InstanceId)
"""looping through instance ids
for instanceid in InstanceId:
# command to be executed on instance
client.start_instances(InstanceIds=InstanceId)
print(output)"""
return {
'statusCode': 200,
'body': json.dumps('Thanks from Srce Cde!')
}
我的任务调度程序上有几个运行 Python 脚本的任务,但是在激活之后,即使服务器正在运行,这些任务也没有运行。
请注意,我已尝试在所有这些上设置“无论是否登录都运行”,但收到与这些任务的权限相关的(0x1)错误
有谁知道如何解决这个问题?有没有其他方法可以在夜间关闭和打开 EC2 AWS win 服务器以节省账单
感谢一百万的帮助者
谢谢,埃迪·阿布拉莫夫
解决方案
推荐阅读
- javascript - 如何从字符串的起始位置检查是否包含字符串
- python - 特定条件下的 Concat DataFrame
- neo4j - 从节点属性设置标签
- javascript - 从格式化程序在表格中添加 CheckBox
- sql - Hive 删除重复类型的关系
- c++ - 使用 srand() 在随机游走中出现蝴蝶模式,为什么?
- flutter - 我们可以在 Flutter 包项目中创建共享库或程序集,如 .dll 吗?
- javascript - 是否有任何方法可以在 javascript 中多次调用 eventListener?
- python - Python - 当进程以退出代码 1 完成时做某事并继续
- reactjs - webpack - 错误:找不到模块'webpack/lib/node/NodeTemplatePlugin'