The retry
tool will do this. As requested, we try 10 times before giving up.
By default, we retry forever.
~$ retry --times 10 -- scp -P 3337 $FILE ibrahimince@localhost:$HOMEDIR/Printed/
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
ssh: connect to host localhost port 3337: Connection refused
scp: Connection closed
retry: scp returned 255, backing off for 10 seconds and trying again...
~$
https://github.com/minfrin/retry
Available out the box in recent Debian, Ubuntu, and Nix.
(Disclaimer, I am the original author of this tool)
#!
marker to identify the interpreter? Please paste it into shellcheck.net to find obvious errorssystem
command, and none is needed: Just put the command directly afterwhile
(no parenthesis), but don't forget to negate the condition (commands return0
on "good" outcomes).shellcheck.net
debug output.