1: #!/usr/bin/perl
2:
3: #This is nothing special but it's the first real perl script I've done and I was interested
4: #in hearing comments and opinions. Sorry if it's a little remedial for everybody but I
5: #think it beats the hell out of a hello world.
6:
7: #This program deletes old unneeded backup logs with the goofy site dependent timestamp
8: #backup.MMDDYY.log.Z
9:
10: $now=time; #WHATS THE CURRENT DATE/TIME
11: $deldate=$now-2419200;
12: #GO BACK 20 WORK DAYS
13: ($seconds,$minutes,$hour,$monthday,$month,$year,$weekday,$yearday,$dst_flag)=localtime($deldate);
14: $month+=1; #FORMAT MONTH
15: $month*=10000;
16: $monthday*=100; #FORMAT DATE
17: $year-=100; #FORMAT YEAR
18: $TS=$year+$month+$monthday; #FORMAT TIMESTAMP
19: if ($TS < 100000) {
20: $TS ="0$TS";
21: }
22: $fullstamp="backup.$TS.log.Z";
23: unlink("/var/adm/$fullstamp"); #DELETE THE OLD LOGFILE