Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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
Domain Nodelet?
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 imbibing at the Monastery: (6)
As of 2022-01-22 13:01 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (62 votes). Check out past polls.