I try to execute a command that returns an error all the time (for example, I start copying a file, but during the recording process it stops or I begin to ping the server, but it does not respond). How to loop this process, so that the command is executed until it is completed with success (like "autodial")?
2 answers
It is much easier to just ignore the signal of loss of communication:
nohup cp ./from ./to |
The easiest way is to execute the command in a loop and until the result of the command is without error
#!/bin/bashuntil cp from to; do echo Ошибка, повтор через секунду sleep 1done Here from and to - non-existent files or files to which there is no access.
|