amazon-web-services - aws ssm send 命令 cli 无法创建文件

标签 amazon-web-services aws-ssm

我尝试使用下面的 aws ssm send-command 在 EC2 实例上创建文件,但它不起作用。

aws ssm send-command --instance-ids i-XXXXXXXXXX --document-name "AWS-RunShellScript"--parameters command="touch/home/hadoop/test2.txt"--output text

输入命令后,命令立即返回并输出以下消息。然后,我检查该 EC2 实例上不存在 test2.txt。任何建议将不胜感激。谢谢。

`命令 AAAAAAAA-ZZZZ-XXXX-YYYY-XXXXXXXXXXXX 0 0 AWS-RunShellScript 0 XXXXXXXXXX.91 50 0 XXXXXXXXXX.91待处理 待处理 1 3600 CloudWatchOutPUTCONFIG 假

实例IDS i-XXXXXXXXXX

通知配置

命令触摸/home/hadoop/test2.txt`

最佳答案

我尝试使用 Amazon Linux 2复制该问题。事实上,该命令失败了。我发现原因是/home/hadoop/文件夹不存在。随后,您将无法触摸不存在的文件夹中的文件。

解决方案是:

aws ssm send-command \
    --instance-ids i-0788cf54681f8bd52 \
    --document-name "AWS-RunShellScript" \
    --parameters commands='["mkdir -p /home/hadoop/","touch /home/hadoop/test2.txt"]' \
    --output text

关于amazon-web-services - aws ssm send 命令 cli 无法创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64288880/

相关文章:

yaml - CloudFormation 提到架构版本 2.2 需要文档类型

node.js - 如何在 Lambda 中使用 putParameter 和 aws-sdk for nodejs 获取过去的错误?

amazon-web-services - AWS 系统管理器启动 session : An error occurred (TargetNotConnected) when calling the StartSession operation: <instance_id> is not connected

amazon-ec2 - 对于 Amazon Web Services 上极短的流量高峰,正确的 Cloudwatch/Autoscale 设置是什么?

node.js - 在 NodeJS Lambas 中访问 AWS SSM 参数

postgresql - 亚马逊 Redshift : Copying Data Between Databases

amazon-web-services - 如何更新 Amazon elasticbeanstalk CLI

amazon-web-services - AWS SSM 描述实例信息找不到我的实例

amazon-web-services - Twilio 如何与 Echo (Alexa) 交互以将语音信号传输至另一台设备或从另一台设备传输语音信号?

amazon-web-services - 将AWS WAF日志从S3传输到ES时没有时间戳记