Scroll to navigation

retry(1) General Commands Manual retry(1)

NAME

retry - Repeat command until a criteria is met, usually success.

SYNOPSIS

retry [-v] [-h] [-u until] [-w while] command ...

DESCRIPTION

The tool repeats the given command until the command is successful, backing off with a configurable delay between each attempt.

Retry captures stdin into memory as the data is passed to the repeated command, and this captured stdin is then replayed should the command be repeated. This makes it possible to embed the retry tool into shell pipelines.

Retry captures stdout into memory, and if the command was successful stdout is passed on to stdout as normal, while if the command was repeated stdout is passed to stderr instead. This ensures that output is passed to stdout once and once only.

OPTIONS

The number of seconds to back off after each attempt.
A message to include in the notification when repeat has backed off. Defaults to the command name.
The number of times to retry the command. By default we try forever.
Keep repeating the command until any one of the comma separated criteria is met. Options include 'success', 'true', 'fail', ’false', an integer or a range of integers. Default is 'success'.
Keep repeating the command while any one of the comma separated criteria is met. Options include 'success', 'true', 'fail', ’false', an integer or a range of integers.
Display this help message.
Display the version number.

RETURN VALUE

The retry tool returns the return code from the command being executed, once the criteria is reached.

If the command was interrupted with a signal, the return code is the signal number plus 128.

If the command could not be executed, or if the options are invalid, the status 1 is returned.

EXAMPLES

In this basic example, we repeat the command forever.


~$ retry --until=success false
retry: 'false' returned 1, backing off for 10 seconds and trying again...
retry: 'false' returned 1, backing off for 10 seconds and trying again...
retry: 'false' returned 1, backing off for 10 seconds and trying again...
^C
In this more complex example, each invocation of curl is retried until curl succeeds, at which point stdout is passed once and once only to the next element in the pipeline.


~$ retry curl --fail http://localhost/entities | \
jq ... | \
retry curl --fail -X POST http://localhost/resource | \
logger -t resource-init

AUTHOR

Graham Leggett <minfrin@sharp.fm>

retry-1.0.4