[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: occasional error on ftp.cz.debian.org



On Sun, Nov 05, 2006 at 07:27:20PM -0500, Simon Valiquette wrote:
> >        $FROM $TO > $LOGFILE.2nd 2>&1
> >  cat $LOGFILE.2nd >> $LOGFILE
> >  rm $LOGFILE.2nd
> 
>   Replace the last line for:
> 
>           $FROM $TO >> $LOGFILE 2>&1
> 
>   That will make the next 2 lines useless and avoid losing logfile.2nd if 
> the script is terminated before the end or if the script is run a second
> time in parallel (the command 'lockfile' in the script will not prevent it
> in some special circumstences).

I don't see how termination before the end would lose anything, but yes,
running parallel scripts would cause horrible results. Yet, they aren't
limited to this snippet - the first rsync also does > $LOGFILE so you could
lose that too. Also, using >> just means that you would scramble $LOGFILE
if you kept appending to it in the middle of another rsync run.

Either way you end up with broken log files, and that problem can't be
resolved with these kinds of adjustments. You could perhaps write log files
named using $$ (PID), or for example not set a lockfile timeout (-l), or
replace lockfile(1) with custom semaphore handling that has not only a
lock file timeout but also logic which kills the old rsync process in
such an event.

-- 
     2. That which causes joy or happiness.



Reply to: