4 releases (stable)

1.1.0 Sep 10, 2025
1.0.1 Sep 9, 2025
0.1.0 May 5, 2024

#638 in Command line utilities

Download history 5/week @ 2025-08-18 2/week @ 2025-08-25 359/week @ 2025-09-08 33/week @ 2025-09-15 5/week @ 2025-09-29 2/week @ 2025-10-06

149 downloads per month

Unlicense

100KB
2.5K SLoC

attempt - a CLI for retrying fallible commands

attempt allows you to retry fallible commands with a delay.

How do I use it?

attempt [BACKOFF] [OPTIONS] [COMMAND]...

# Rerun database migrations if the server was not ready
attempt --retry-if-contains "server not ready" sqlx migrate

# Use an exponential backoff
attempt exponential --retry-if-contains "server not ready" sqlx migrate

What can I do with it?

  • Wait for a service to start when you aren't restricted to bash
  • Write robust scripts accessing resources which may become temporarily unavailable
  • Bodge flaky programs into working

Key features

  • Simple.
    • The featureset is small but flexible enough to covers most usecases.
    • The codebase can be audited in an afternoon.
  • Robust.
    • It provides the tools you need to implement fault tolerance, like timeouts, jitter, and exponential backoff.
    • The test suite is extensive and contains both end-to-end and unit tests.
  • Free forever.
    • The codebase is in the public domain.
    • All future versions will be released under the same license.

Documentation

  • See the usage instructions to get a quick start
  • The scripting guide has advice about using attempt in scripts
  • Read the user manual for full documentation
  • Run attempt --help for quick access to documentation
    • Note that you need to specify a strategy to see it's parameters, eg attempt exponential --help

Known issues

  • attempt assumes that the child command's output will be UTF-8 encoded. If any output predicates are used on a program that outputs invalid UTF-8, attempt will crash.
  • attempt --help will not reflect that the fixed strategy will be used if no strategy is specified.

Installation

cargo install attempt-cli

Dependencies

~4.5–6MB
~111K SLoC