Retry any command with exponential backoff. One tool, one job.
Shell retry loops suck. You rewrite them constantly, get the backoff wrong, and forget 2>&1. retry handles it so you don't have to.
# Instead of this:
for i in 1 2 3 4 5; do
curl https://api.com && break
sleep $((2**i))
done
# Do this:
retry -t 5 -b exp -- curl https://api.comcurl -sSL https://raw.githubusercontent.com/0xProgress/retry/main/install.sh | shThis clones the repo, builds it with make, and installs the binary to /usr/local/bin (or $PREFIX if set). Requires git, make, and Go on your PATH to build — the resulting binary itself is a single static executable with zero runtime dependencies.
Prefer to build manually?
git clone https://github.com/0xProgress/retry.git
cd retry
make build
cp retry /usr/local/bin/retry # or wherever you keep binariesOr, if you just want it on your $GOPATH/bin:
go install github.com/0xProgress/retry@latest# Retry up to 3 times
retry --times 3 -- ping google.com
# Exponential backoff (1s → 2s → 4s → 8s)
retry -t 5 -b exp -- curl -s https://flaky-api.com
# Fixed interval (every 5 seconds)
retry -t 10 -d 5 -- npm publish
# Only retry on specific errors
retry -t 3 --retry-if "Connection refused|timeout" -- ./my-script| Flag | Description | Default |
|---|---|---|
-t, --times N |
Max attempts | 5 |
-d, --delay N |
Base delay in seconds | 1 |
-b, --backoff TYPE |
linear, exp, or fixed |
linear |
--retry-if RE |
Only retry if stderr matches regex | (all failures) |
-v, --verbose |
Show attempt timing | off |
--no-color |
Disable color output | auto-detected |
--version |
Print version | — |
-h, --help |
Show help | — |
| Code | Meaning |
|---|---|
0 |
Command succeeded |
1 |
Failed after all retries |
2 |
Invalid arguments |
3 |
Command not found |
128+N |
Command was terminated by signal N (e.g. 130 = SIGINT) |
CI pipeline
- name: Deploy
run: retry -t 3 -b exp -- eb deployDatabase migrations
retry -t 10 --retry-if "deadlock|timeout" -- \
psql -c "ALTER TABLE users ADD COLUMN email_verified BOOLEAN;"Flaky tests
retry -t 3 -v -- go test ./pkg/integration/...Part of the 0× suite — tools that do one job, have zero bloat, and stay out of your way.
- No config files
- No runtime dependencies (single static binary once built)
- No surprises
--helpis all the docs you need
Licensed under MIT