C
Clifford Bracht
I was asked to create a Perl script that is able to when it runs
delete Performance logs that are 30 days old from the current date on
a Windows Platform. I didn't know Pearl prior to this and this is
only after about 5 days of trying to teach myself. Here is my code. I
was just wondering if anyone could lend some helpful suggestions that
could maybe clear things up or get me going on the right path if I'm
not already there. Thanks
use Date::Calc qwall);
eval
{
($year,$month,$day, $hour,$min,$sec, $doy,$dow,$dst) = System_Clock();
};
#$days = Date_to_Days($year,$month,$day);
#($year,$month,$day) = Add_Delta_Days(1,1,1, $days - 1);
$day_diff = Delta_Days($year1, $month1, $day1, $year2, $month2,
$day2);
$checkdate ($year1, $month1, $day1) = (@logdate); #Date Associated
with the first or oldest perflog file
$currentdate ($year2,$month2, $day2) = (Today([$gmt]); #Current Date
$counterlog = ("C:\PerfLogs\system\");
$tracelog = ("C:\PerfLogs\system\"); #Directory of the log files
$alertlog = ("C:\PerfLogs\system\");
@logarray("$counterlog","$tracelog","$alertlog",); #Array of the
three performance logs
@logdate("$logdate1","$logdate2","$logdate3",)
if (($year,$month,$day) = Decode_Date_US($counterlog);
{
$counterlog = $logdate1;
}
else if
{
(($year,$month,$day) = Decode_Date_US($tracelog);
$tracelog = $logdate2;
}
else if
{
(($year,$month,$day) = Decode_Date_US($tracelog);
$alertlog = $logdate3;
}
else
{
exit;
};
#Reads in each Performance counter and checks the difference in days
against 30 days
for ($logcounter = 0; logcounter <= $#logarray; logcounter++)
{
while ($day_diff >= 30)
{
delete $checkdate;
}
else
print "All files are current; No log files where deleted \n";
}
exit;
delete Performance logs that are 30 days old from the current date on
a Windows Platform. I didn't know Pearl prior to this and this is
only after about 5 days of trying to teach myself. Here is my code. I
was just wondering if anyone could lend some helpful suggestions that
could maybe clear things up or get me going on the right path if I'm
not already there. Thanks
use Date::Calc qwall);
eval
{
($year,$month,$day, $hour,$min,$sec, $doy,$dow,$dst) = System_Clock();
};
#$days = Date_to_Days($year,$month,$day);
#($year,$month,$day) = Add_Delta_Days(1,1,1, $days - 1);
$day_diff = Delta_Days($year1, $month1, $day1, $year2, $month2,
$day2);
$checkdate ($year1, $month1, $day1) = (@logdate); #Date Associated
with the first or oldest perflog file
$currentdate ($year2,$month2, $day2) = (Today([$gmt]); #Current Date
$counterlog = ("C:\PerfLogs\system\");
$tracelog = ("C:\PerfLogs\system\"); #Directory of the log files
$alertlog = ("C:\PerfLogs\system\");
@logarray("$counterlog","$tracelog","$alertlog",); #Array of the
three performance logs
@logdate("$logdate1","$logdate2","$logdate3",)
if (($year,$month,$day) = Decode_Date_US($counterlog);
{
$counterlog = $logdate1;
}
else if
{
(($year,$month,$day) = Decode_Date_US($tracelog);
$tracelog = $logdate2;
}
else if
{
(($year,$month,$day) = Decode_Date_US($tracelog);
$alertlog = $logdate3;
}
else
{
exit;
};
#Reads in each Performance counter and checks the difference in days
against 30 days
for ($logcounter = 0; logcounter <= $#logarray; logcounter++)
{
while ($day_diff >= 30)
{
delete $checkdate;
}
else
print "All files are current; No log files where deleted \n";
}
exit;