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