我尝试使用下面的 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/