Question

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?

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top