Monday, July 20, 2015

Perl script to zip native logs in websphere

#!/usr/bin/perl
my $dir='/websphere/logs';  (set to your log path directory)
if( -d $dir )
{
@jvmlist=`ls $dir/ |grep jvm`;   (grep for the content of your appserver name)
foreach(@jvmlist)
{
chomp($_);
my $loglist=`find $dir/$_/ -type f -name native_stderr.log -size +10k`;  (decide the size to zip)
if(length($loglist) > 0 )
{
print $loglist;
chdir "$dir/$_";
my $dat=`date +%d-%m-%y`;
chomp($dat);
`gzip -c native_stderr.log > nativelog_$dat.gz ; > native_stderr.log`;
}
}
}

No comments:

Post a Comment

Your suggestions please