Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Emptying log file

by imp (Priest)
on Jan 31, 2007 at 16:52 UTC ( [id://597564]=note: print w/replies, xml ) Need Help??


in reply to Emptying log file

If possible I would use an existing utility for this, likely logrotate. If not then I would look to existing modules as they have probably done a reasonable amount of testing. At a glance Logfile::Rotate seems reasonable, but I don't have any personal experience with it.

Replies are listed 'Best First'.
Re^2: Emptying log file
by RobPayne (Chaplain) on Jan 31, 2007 at 17:12 UTC
    There are a number of existing tools that can be used for logfile rotation (such as logrotate) and cleanup of old files (like tmpwatch). Those may or may not suit the purposes of the OP. If the requirement is to name the old log files based upon the date of the rotation, logrotate can accomplish that.

    The problem with rolling your own log file rotation script, as with other system utilities is that you need to take other issues into account, such as making sure that removal of old files does not remove the wrong file (such as removing /etc/passwd when /var/log/messages is a symbolic link to it.) Does your rotation script need to rotate the logs when the disks are filling up? As imp said, the existing tools have been well-tested, whatever tool you write will also need to be tested carefully.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found