Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Simple Log Rotate Problem

by particle (Vicar)
on Nov 13, 2003 at 22:09 UTC ( #306948=note: print w/ replies, xml ) Need Help??

in reply to Simple Log Rotate Problem

when you move the file, doesn't that delete it?

from the File::Copy docs

* The "move" function also takes two parameters: the current nam +e and the intended name of the file to be moved. If the destination already exists and is a directory, and the source is not a directory, then the source file will be renamed into the direc +tory specified by the destination. If possible, move() will simply rename the file. Otherwise, it copies the file to the new location and deletes the original. +If an error occurs during this copy-and-delete process, you may be l +eft with a (possibly partial) copy of the file under the destinati +on name. You may use the "mv" alias for this function in the same way t +hat you may use the "cp" alias for "copy".

of course unlink is failing!

~Particle *accelerates*

Comment on Re: Simple Log Rotate Problem
Download Code
Re: Re: Simple Log Rotate Problem
by waswas-fng (Curate) on Nov 13, 2003 at 22:16 UTC
    I prefer to cp/truncate instead of deleting. That way you do not have to worry about restarting the service that has the file open for logdumping. on commandline it looks like this:
    rm logfile.5 mv logfile.4 logfile.5 mv logfile.3 logfile.4 mv logfile.2 logfile.3 mv logfile.1 logfile.2 cp logfile logfile.1 cat /dev/null > logfile
    its about the same thing in perl except you use File::Copy's copy and move and open OUTFILE, ">logfile"; close OUTFILE; to truncate


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://306948]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2014-07-10 00:39 GMT
Find Nodes?
    Voting Booth?

    When choosing user names for websites, I prefer to use:

    Results (198 votes), past polls