Hands-on task
Retry with increasing delays
The command /usr/local/bin/flaky.sh is unreliable: the first calls fail, and from some attempt on it succeeds. Write /root/retry.sh that calls it repeatedly up to five times, pausing between attempts with a delay that doubles each time (1, 2, 4, …). The script must exit with code 0 as soon as the command succeeds, and with a non-zero code if all attempts are used up. Use the sleep command for the pauses. Make the script executable.
- retry
- exponential backoff
- exit codes
- arithmetic expansion
- loops