質問

Sometimes commands like apt-get update -q fail randomly in a cloudformation template user-data script. What's the proper way to retry them till they succeed?

役に立ちましたか?

解決

As @shellter pointed out:

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帰属
所属していません StackOverflow
scroll top