XAS::Apps::Rotate - Rotate files based on a config file
use XAS::Apps::Rotate; my $app = XAS::Apps::Rotate->new( -throws => 'rotate', -facility => 'systems', -priority => 'warn', ); exit $app->run;
This module is used to rotate files.
The configuration file uses the standard windows .ini file. It has the following format.
[settings] compressor = zip - default file compressor zip-command - zip command defaults to 'c:\bin\zip.exe' gzip-command - gzip command defaults to 'c:\bin\gzip.exe' bzip2-command - bzip2 command defaults to 'c:\bin\bzip2.exe' compress-command - compress command defaults to 'c:\bin\compress.exe' tail-command - tail command defaults to 'c:\bin\tail.exe' [log\test.log] - file to process, may have DOS wildcards compress = true - wither to compress the file method = move - how to handle the file missingok = false - whither a missing file is OK lines-or-files = files - create-new = false - create a new file after rotation modify-age - process based on last modification create-age - process based in creation time file-size - process based on file size ifempty - process if file is empty file-count - number of rotated files kept line-count - how many line to transfer to new file prolog - command to process before rotation epilog - command to process after rotation pause - number of seconds to pause after prolog and epilog
Process the configuration file.
Run a command and capture the output to the log file.
The command to run.
Return the file extension base on compressor type.
Return TRUE or FALSE based on $param. If $param is 'true', or 1 then TRUE.
Return TRUE or FALSE based on $param. If $param is 'false' or 0 then TRUE.
Parses $age_diff and checks to see if the $age is newer than the current time minus $age_diff. That is we return TRUE if a file is too new based on the criteria $age_diff and $age and the implicit parameter: the current time.
Parses $size_spec and checks to see if the $size is bigger than that. We return TRUE if a file is too big.
Compress the file based on chosen compression type.
The file to compress
Recreate the file if needed. This checks the file-or-line config item. If it is 'file' then a new file is created, if it is 'lines' then the config item 'line-count' is used to copy that number of lines from the end of the file into the beginning of the new file.
The file to recreate.
Perform the basic file rotation.
The file to rotate.
Process the selected files. It preforms the following actions:
Scan the local directory looking for files to rotate.
Rotate
Kevin L. Esteb, <kevin@kesteb.us>
Copyright (C) 2014 Kevin L. Esteb
TThis is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.
To install XAS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XAS
CPAN shell
perl -MCPAN -e shell install XAS
For more information on module installation, please visit the detailed CPAN module installation guide.