Skip to content

Retry

Index

retry::with_linear_backoff

Retry a command with linear backoff. Sleeps base_sleep * attempt seconds between retries. Dies via log::die if the command does not succeed within max_tries attempts.

Arguments

  • $1 (max_tries): (positive integer)
  • $2 (base_sleep_seconds): (positive integer; sleep grows linearly: base, base2, base3, ...)
  • ... (command): and args to run (variadic, at least one)

Exit codes

  • 0: if the command succeeds within max_tries attempts

retry::until_success

Retry a command indefinitely until it succeeds, with no sleep between attempts. Intended for interactive prompts (e.g. passphrase entry) where the user reacts immediately to failure and backoff would only add friction. No max-attempt cap — the caller's command must provide its own escape hatch (e.g. SIGINT) if the operation should not be retried forever.

Arguments

  • ... (command): and args to run (variadic, at least one)

Exit codes

  • 0: once the command succeeds

retry::with_exponential_backoff

Retry a command with exponential backoff. Sleeps base_sleep * 2^(attempt-1) seconds between retries. Dies via log::die if the command does not succeed within max_tries attempts.

Arguments

  • $1 (max_tries): (positive integer)
  • $2 (base_sleep_seconds): (positive integer; sleep grows exponentially: base, base2, base4, ...)
  • ... (command): and args to run (variadic, at least one)

Exit codes

  • 0: if the command succeeds within max_tries attempts