#!/usr/bin/perl
$dir='/home/websphere/WebSphere/AppServer/profiles/AppSrv01/logs/server1';
$file = 'SystemErr.log';
$mon_file="$dir/$file";
print "\$mon_file is $mon_file\n";
@warn_arr = qw/连接已关闭 NullPointException IndexOutOfBound/;
foreach $a (@warn_arr){
open (C,"<","$a.tmp") ;
while (<C>){
$count = $_;
}
print "\$count is $count\n";
$info =`tac $mon_file | grep "$a" | head -1`;
Perl 打印特定行日志
最新推荐文章于 2024-06-12 08:10:16 发布
本文介绍了一个使用Perl编写的脚本,该脚本在/home/websphere/WebSphere/AppServer/profiles/AppSrv01/logs/server1目录下的SystemErr.log文件中,针对'连接已关闭'、'NullPointException'和'IndexOutOfBound'等错误,查找相关警告,并打印出这些错误出现的上下10行内容。通过临时文件$a.tmp存储计数和匹配信息,脚本实现了日志分析和特定行的提取。
摘要由CSDN通过智能技术生成