I encourage my Rivendell clients to name their logs "monday", "tuesday",
"wednesday", "thursday", "friday", "saturday", and "sunday"; that way, if
someone forgets to create a log, last week's log will run by default
instead of no log.
Recently I discovered that rdlogmanager can be run from a cron job. I
wrote the following script (genlog.pl) to generate logs automatically:
#!/usr/bin/perl
# ==> GENERATE LOG (genlog n: create log for +-n days from today)
sub getdate {
@a = localtime($_[0]);
$wday = $a[6];
$day = ('00','01','02','03','04','05','06','07','08','09',
'10','11','12','13','14','15','16','17','18','19',
'20','21','22','23','24','25','26','27','28','29',
'30','31')[$a[3]];
$month = ('01','02','03','04','05','06','07','08','09',
'10','11','12')[$a[4]];
$year = substr($a[5],1,2);
$y = 2000 + $year;
$m = $month;
$d = $day;
$file = "$year$month$day.txt";
}
sub log {
my $t = localtime(time);
my $a = shift;
if (open(LOG,">>$LOG")) {
print (LOG "$t\t$a\n");
close LOG;
}
}
# ==> MAIN PROGRAM
$SERVICE = 'Beacon';
$LOG = '/home/nowplayd/log/genlog.log';
# ==> GET DATE
$seconds = 86400 * $ARGV[0]; $offset = $ARGV[0] - 1; &getdate(time +
$seconds); $log =
('z0sunday','z0monday','z0tuesday','z0wednesday','z0thursday',
'z0friday', 'z0saturday')[$wday];
&log("Generating $log");
system("rdlogmanager -g -d $offset -s $SERVICE >> $LOG");
&log("Log generated");
Rob
--
Я там, где ребята толковые,
Я там, где плакаты "Вперёд",
Где песни рабочие новые
Страна трудовая поёт.
_______________________________________________
Rivendell-dev mailing list
[email protected]
http://caspian.paravelsystems.com/mailman/listinfo/rivendell-dev