This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to repeat a bash shell script until success


On 7/14/2017 1:27 AM, Gary Johnson wrote:
> 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.
> 

In reality the OP script appears to be executed in a crontab system and
executed every X minutes.  So a change to the OP question is needed
which is answered at[1].  Let's remember some people have no real clue
as to what question they should ask and we need to interpret what is
being asked into what should have been asked.  If interpretation isn't
possible then asking for a use case would be warranted.

[1]
https://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows

-- 
cyg Simple

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]