20 lines
402 B
Bash
Executable File
20 lines
402 B
Bash
Executable File
#!/bin/bash
|
|
# retry.sh — 5 attempts, 120s between, for transport failures only.
|
|
# usage: retry.sh <cmd> [args...]
|
|
set -u
|
|
n=0
|
|
max=5
|
|
while [ "$n" -lt "$max" ]; do
|
|
n=$((n+1))
|
|
echo "[retry] attempt $n/$max: $*" >&2
|
|
if "$@"; then
|
|
echo "[retry] success on attempt $n" >&2
|
|
exit 0
|
|
fi
|
|
if [ "$n" -lt "$max" ]; then
|
|
sleep 120
|
|
fi
|
|
done
|
|
echo "[retry] failed after $max attempts" >&2
|
|
exit 1
|