NAME

Logfile::Rotate - Perl module to rotate logfiles.

SYNOPSIS

   use Logfile::Rotate;
   my $log = new Logfile::Rotate( File  => '/var/adm/syslog', 
                                  Count => 7,
								  Gzip  => '/usr/local/bin/gzip' );

   # process log file 

   $log->rotate();

   or
   
   my $log = new Logfile::Rotate( File  => '/var/adm/syslog', 
								  Gzip  => 'no' );
   
   # process log file 

   $log->rotate();
   undef $log;

DESCRIPTION

I have used the name space of Logfile::Base package by Ulrich Pfeifer, as the use of this module closely relates to the processing logfiles.

new

new accepts three arguments, File, Count, Gzip, with only File being mandatory. new will open and lock the file, so you may coordindate the your processing of the file with rotating it. The file is closed and unlocked when the object is destroyed, so you can do this explicity by undef'ing the object.

rotate()

It will copy the file passed in new to a file of the same name, with a numeric extension and truncate the original file to zero length. The numeric extension will range from 1 up to the value specified by Count, or 7 if none is defined, with 1 being the most recent file. When Count is reached, the older file is discarded in a FIFO (first in, first out) fashion.

The copy function is implemented by using the File::Copy package.

Optional Compression

If available rotate will also compress the file with the gzip program or the program passed as the Gzip argument. If no argument is defined it will also check the perl Config to determine if gzip is available on your system. In this case the gzip must be in your current path to succeed, and accept the C-f option.

See the "WARNING" section below.

WARNING

A system call is made to gzip this makes this module vulnerable to security problems if a rogue gzip is in your path or gzip has been sabotaged. For this reason a STRONGLY RECOMMEND you DO NOT use this module while you are ROOT, or specify the Gzip argument.

DEPENDANCIES

See File::Copy.

If Gzip is being used it must create files with an extension of .gz for the file to be picked by the rotate cycle.

SEE ALSO

File::Copy, Logfile::Base.

RETURN

All functions return 1 on success, 0 on failure.

AUTHOR

Paul Gampe <paulg@twics.com>