Pergunta

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?

Foi útil?

Solução

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top