|
NAMELogfile::Rotate - Perl module to rotate logfiles.SYNOPSISuse Logfile::Rotate; my $log = new Logfile::Rotate( File => '/var/adm/syslog/syslog.log', Count => 7, Gzip => 'lib', Post => sub{ open(IN, "/var/run/syslog.pid"); kill("HUP", chomp(<IN>)); } Dir => '/var/log/old', Flock => 'yes', Persist => 'yes', ); # process log file $log->rotate(); or my $log = new Logfile::Rotate( File => '/var/adm/syslog', Gzip => '/usr/local/bin/gzip'); # process log file $log->rotate(); undef $log; DESCRIPTIONI have used the name space of Logfile::Base package by Ulrich Pfeifer, as the use of this module closely relates to the processing logfiles.
Optional CompressionIf available "rotate" will also compress the file with the gzip program or the program passed as the "Gzip" argument.You may now also use "lib" as a value for the "Gzip" argument. This directs the program to load the "Compress::Zlib" module, if available and use it do the compression within perl. This avoids the security issues associated with spawning external programs and is the recommended value for this option. If no argument is defined it will first check to see if the "Compress::Zlib" module can be loaded then 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 "-f" option. See the "WARNING" section below. Optional Relocation DirectoryIf you specify an argument for "Dir" then the file being rotated will be relocated to the directory specified. Along with any other files that may have been rotated previously. If the directory name specified does not exist then it will be created with 0750 permissions. If you wish to have other permissions on the directory then I would recommend you create the directory before using this module.See the "WARNING" section below. WARNINGIf 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.For a more secure alternative install the "Compress::Zlib" module and use the lib value for the "Gzip" argument. If you specify an argument for "Dir" and the directory name you pass does not exist, this module will create the directory with permissions 0750. DEPENDANCIESSee 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. COPYRIGHTCopyright (c) 1997-99 Paul Gampe. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN ``AS IS'' BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. SEE ALSOFile::Copy, Logfile::Base, flock Changes file for change history and credits for contributions.RETURNAll functions return 1 on success, 0 on failure.AUTHORPaul Gampe <paulg@apnic.net>
Visit the GSP FreeBSD Man Page Interface. |