How to run a command in your shell until it succeed

Mayeu on August 11, 2018

I am regularly copying big files over the internet via rsync, and since I am travelling a lot, I don't generally have access to stable internet c... [Read Full]
markdown guide

To maximize laziness, you can make it into a function called retry() and have the rsync command as the first argument.


Yup, but I'm too lazy to maximize my laziness :D

Anyway, if somebody is wondering, something like that should do it (ugly, may be unsafe, you are warned):

function retry() {
  until $1 ;
    echo "Retrying at `date -Iminutes`";

Hey, thank you for your reply :)

This is not really the same, thefuck correct spelling errors of the previous command you do. While using until will perpetually re-run the command until the exit code is 0 (i.e.: until it is a success).

In the case of rsync that allow you to continue the download until it succeed :)

code of conduct - report abuse