How to repeat a bash shell script until success
Gary Johnson
garyjohn@spocom.com
Fri Jul 14 13:06:00 GMT 2017
On 2017-07-12, Bryan Dunphy wrote:
> I have a shell script, originally created for Mac OS X. that waits
> for an external drive to be mounted (by testing an âlsâ of the
> volumeâs root directory for success) then runs an ârsyncâ command.
> How do I get the script to be run repeatedly until successful exit
> under Cygwin?
>
> Here is the unmodified Mac OS version of the script:
>
> #!/bin/bash
> if ls /Volumes/Shared >/dev/null 2>/dev/null
> then
> rsync -avz --compress-level=9 --delete-during --partial --exclude 'cache/' aleph.gutenberg.org::gutenberg /Volumes/Shared/Project-Gutenberg
> exit 0
> else
> exit 1
> fi
Let the name of your script be "myscript". The following will run
myscript every two seconds until it succeeds.
while ! myscript; do sleep 2; done
This is really a bash programming question and is not specific to
Cygwin.
Regards,
Gary
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list