On Wed, 22 Dec 1999,  Gevaerts Frank wrote about,  Re: timed file copy.:
> 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.

Well i had a vistor here a while ago, he writes all sorts of programs in
both dos and unix, he was of the opinion that in the case that was asked,
How do i cp a file evey 20 seconds, we could conclude=

1) Its quite possably a small file, why on earth a file would need to be
cp'ed every 20 sec;s eludes both him and me, but the question was asked.
2) You should in most cases keep it "simple" whats called the kiss method,
Keep It Simple Stupid. As the sying goes. (That is said in gerneral and not
ointed at anyone or anything)
3) Keeping it to a minumum keeps silly little side effects at bay.
4) Rays script in perl was the best, but mine was the most to the point,
and was in the tradional style, "kiss".
5) His comments, Why go from point a to b and visit all points inbetween
when we could take a direct road and aviod all points in between, simply
because there is no need to visit them in this case.
6) The only piece of code he realy commented on was the C prog, it does
not work, or at least the way it looks like it should.


> > 
> > ------------------------------------"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!
-- 
Regards Richard
[EMAIL PROTECTED]
http://people.zeelandnet.nl/pa3gcu/
Merry Xmas.

Reply via email to