简体   繁体   English

重试AWS CFN模板中的命令的正确方法是什么?

[英]What's the proper way to retry commands in an AWS CFN template?

Sometimes commands like apt-get update -q fail randomly in a cloudformation template user-data script. 有时,诸如apt-get update -q类的命令在cloudformation模板用户数据脚本中会随机失败。 What's the proper way to retry them till they succeed? 重试它们直到成功的正确方法是什么?

As @shellter pointed out: 正如@shellter指出的那样:

while ! apt-get update -q ; do sleep 1; done

Or, for a script: 或者,对于脚本:

while ! apt-get update -q
do
    echo "Failed. Trying again..." >&2
    sleep 1
done

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

相关问题 用户创建和保存“别名”命令的最佳方法是什么? - What's best way for create and save 'alias' commands by user? 测试 Bash 函数返回值的正确方法是什么? - What is the proper way to test a Bash function's return value? AWS Cloudformation - 使用 cfn-init 安装软件包 - AWS Cloudformation - Installing packages with cfn-init 安装Jekyll的正确方法是什么? - What is the proper way to install Jekyll? 在JS模板字符串中转义$ {}的正确方法 - Proper way to escape ${} in a JS template string 显示正在运行的SSH命令的正确方法 - Proper way to show which SSH commands you are running 从制表符完成历史中删除已删除分支的最正确方法是什么? - What's the most proper way to remove an already deleted branch from tab-completion history? 混合远程期望脚本和本地bash命令的最佳方法是什么? - What's the best way to mix remote expect scripts and local bash commands? 通过 brew 安装了 mysql 但终端找不到它。 在 macos 上别名的正确方法是什么? - Installed mysql via brew but terminal can't find it. What's the proper way to alias it on a macos? 在运行脚本时通过 ssh 发送多个命令的最佳方法是什么? - What's the best way to send multiple commands via ssh whilst running a script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM