On Tue, 21 Dec 1999, Ray Olszewski wrote:

> I don't think this solves the problem I was identifying. 
> 
> First, since you don't fork a separate process for the cp commmand, the

yes it does. Notice the & . I tested it here (with sleep instead of cp)
There are some problems left : 
   mkdir/rmdir are not atomic and should be replaced by e.g. mv
   forking the cp process takes some time (although it should be very
short), so the interval will be 20.00??? seconds instead of 20. This could
be solved by using :
expr `date +"%S"` % 20

Frank

> script will block waiting for the cp command to return success. An
> indeterminate amount of time will pass. After the cp command returns control
> to the script, the script will then wait for 20 seconds before starting the
> next copy. In the nature of things, the next attempt will never encounter a
> lock, because the 20-second sleep doesn't begin until the cp is complete.
> 
> THe problem I was noting is that if the cp takes considerably time, say 15
> seconds, the copy cycle will be 15+20 seconds, or every 35 seconds instead
> of every 20. The code in my perl program was an attempt to avoid this
> problem -- that is, to sleep for 20 sec minus however long the cp took. It
> doesn't solve the problem of a cp that takes more than 20 seconds to execute
> .... I suspect that is unsolvable within the contstaints of the problem.
> 
> At 11:02 PM 12/21/99 +0100, Gevaerts Frank wrote [in part]:
> >> 
> >if  you want to be sure :
> >
> >while true
> >do
> >   if [ -d /tmp/$$.lck ]
> >   then
> >      echo "still copying"
> >   else  
> >      (mkdir /tmp/$$.lck ; cp $1 $2 ;rmdir /tmp/$$.lck) &
> >   fi
> >   sleep 20
> >done
> >
> >That should be more or less reliable, even for large copies (it might
> >skipp a copy if the previous one is not done.
> 
> ------------------------------------"Never tell me the odds!"---
> Ray Olszewski                                        -- Han Solo
> Palo Alto, CA                                  [EMAIL PROTECTED]        
> ----------------------------------------------------------------
> 
> 

HI! I'm a .signature virus! cp me into your .signature file to help me spread!

Reply via email to