[Exim] Alternate log cycle program

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Sherwood Botsford
Dátum:  
Címzett: Exim List
Tárgy: [Exim] Alternate log cycle program
I found that I didn't like the nameing convention in the exicycle
program that ships with exim. If I needed to look up a message,
I had problems figuring which file I wanted to look at.

I wrote my own, in perl, which has the following differences:

1. By default it keeps 30 days worth of logs instead of 10.
2. It gzip's the file.
3. It names the file <file>.<yy>-<mm>-<dd>.gz
where <file> is the rootname of the file and the
rest is a date stamp.

Note that due to local conventions, you will have to
do some editing to use this script. (Our convention
here is that addon software goes in /opt/<package>/bin
with some consolidation for packages that consist of a
small number of binaries. E.g. gnu utiltilities.)

Note also that it does not grovel though the exim configure file
to find out the names of log files. Adding code to
run as the exim user is left to the student.

Gotchas:
A. Check path to perl. This should run under perl 4 as well.
B. Check paths for date, find and xargs.
C. Verify that date understands the format string.
D. Adjust for the presence of procmail logs or other logs.
Note that I don't use the suffix .log on my main, reject files.
E. Adjust value of keep.



Sherwood Botsford     | sherwood@???
Sorcerers Apprentice    | Math Dept, U of A, Edmonton, AB T6G 2G1
System Administrator    | Tel: 780 492 5728 
Trouble shooter            | Fax: 780 492 6826



#!/opt/perl5/bin/perl

$date = "/opt/gnu/bin/date";
$find = "/opt/gnu/bin/find";
$xargs = "/opt/gnu/bin/xargs";
$gzip = "/opt/gnu/bin/gzip";

$suffix = `$date +%y-%m-%d`;
chop $suffix;
$keep = 30;

$spool = "/var/spool/exim/log";



$main = "$spool/main";
$reject = "$spool/reject";
$procmail = "$spool/procmail";

rename ($main, "$main.$suffix");
rename ($reject, "$reject.$suffix");
rename ($procmail, "$procmail.$suffix");

#system "$find $spool -mtime +$keep -ls";
system "$find $spool -mtime +$keep | $xargs rm -f ";

system ("$gzip $spool/*-[0-3][0-9]");