Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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
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


    -Waswas

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2015-07-30 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls