[ale] bash question

Greg Freemyer greg.freemyer at gmail.com
Mon Apr 30 19:34:09 EDT 2007


On 4/30/07, David Tomaschik <ozone at webgroup.org> wrote:
> Greg Freemyer wrote:
> > All,
> >
> > I'm experiencing rsync timeouts, so I want to keep invoking it
> > repeatedly until it either finishes or 3 hours have gone by.  When it
> > times out the return code is 30.
> >
> > I'm thinking this might work, but I don't have a great way to test it.
> >  So could a couple bash experts review it.  I've tried it and at least
> > I don't seem to have any syntax errors.
> >
> > Also, I tested the for loop logic with a simple sleep and it worked.
> > It is the break logic I can't test easily.
> >
> > ===
> > #!/bin/bash
> >
> > START=`date +%s`
> > MAX_TIME='10800'   # number of seconds in 3 hours
> >
> > for (( DELTA=0 ; DELTA < MAX_TIME; DELTA = NOW - START))
> > do
> >         rsync -a
> > --partial-dir=/home/forensic1000/forensic1000/transfer ... [Lots more
> > args]
> >         NOW=`date +%s`
> >         if [ $? != 30 ]
> >         then
> >             break;
> >         fi
> > done
> > ===
> >
> > Thanks
> > Greg
> >
> That looks reasonable to me, but will break on any error other than
> timeout.  I would suggest comparing to 0 so you continue on any error.
> Admittedly, that could end up in an infinite loop... perhaps some sort
> of max retries is in order.
>
> David

I might try to convert the if to a case statement tomorrow.  I could
at least send myself an e-mail about an unexpected termination code.

Anyway, I'm leaving for the night.

Thanks
Greg
-- 
Greg Freemyer
The Norcross Group
Forensics for the 21st Century



More information about the Ale mailing list