Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Last active December 25, 2022 22:08
Show Gist options
  • Save jamescherti/995add1dcbf3080dfa25cf372287cca9 to your computer and use it in GitHub Desktop.
Save jamescherti/995add1dcbf3080dfa25cf372287cca9 to your computer and use it in GitHub Desktop.
Shell: Retry a command until it succeeds.
#!/usr/bin/env bash
# Description: Retry a command until it succeeds.
# Author: James Cherti
# License: MIT
# URL: https://gist.github.com/jamescherti/995add1dcbf3080dfa25cf372287cca9
echo "[RUN] $*" >&2
while true; do
if "$@"; then
break
else
sleep 1
echo "[RUN AGAIN] $*" >&2
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment