Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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*

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-06-19 02:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.