The following Bash snippet will repeat a command with the given delay until it succeeds.
while [ "$?" -gt "0" ] ; do
sleep 120 # delay in seconds between retries
# insert command to retry here
done
Unix processes return integers when they exit. These values can be read via $? in Bash. As a matter of convention, a process that completes without errors will return 0, so by checking for exit codes greater than zero we can detect errors and retry.
