Log
#!/bin/perl use
Encode;
Open (notesfiles, $ARGV [0]);
my%errormeganotes;
Print
">>>>>>>>>>>>>>", $
argv[0], "<<<<<< <<<<\n ";
while (<NOTESFILES>) {
if ($_=~/^ (\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}) \s+error\s+ (. *) \s/g
) {
if ($errorMeganotes {$}) {
push @{$errorMeganotes {$2}},$1
}} else{
$errorMeganotes {$2}=[$1];
}}} for (keys%errormeganotes) {my
$tmp _keys=$_;
My @tmp_array = @{$errorMeganotes {$tmp _keys}};
Print "Error number:>>", scalar
(@tmp_array), "<<\n", Encode ("GBK", Decode
("UTF-8", $tmp _keys) ), "\ n", Join
(", \ T", @tmp_array), "\n\n\n";
}
Sh
#!/bin/sh
nowDate=$(date-d'-1day'+%Y-%m-%d);
echo$nowDate
perl/data/apps/shell/meganotesErrorLog.pl/data/apps/meganotes/tomcat/l ogs/app/app.log.$nowDate> _tmp_$nowDate;
perl/data/apps/shell/meganotesErrorLog.pl/data/apps/schedule/tomcat/lo gs/app/app.log.$nowDate >>_tmp_$nowDate;
mail-s$nowDate-ERROR-log my@mail.com < _tmp_$nowDate;
rm_tmp_$nowDate;
Results:
>>>>>>>/data/apps/meganotes/tomcat/logs/app/ap p.log.2009-02-18<<<<<< <<<
Error number:>>2<<
Musicactionoplogproxy:142-music.populartime=[invalid field value for field "Music.populartime".]
2009-02-18 15:53:54, 2009-02-18 16:00:12
。。。。。。