Sunday, July 27, 2008

Monday, July 14, 2008

The iPhone has arrived.



http://www.geekculture.com/joyoftech/joyarchives/1128.html

Wednesday, July 9, 2008

Log rotate final solution


#!/usr/bin/perl -w
use strict;

my $numDays = 7; #Number of days to retain Output Directories
my $numLongDays = 30; #Number of days to reatain archived tars

#get the current date time and break up
my ($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);

#create date stamp
$year = $year + 1900;
my $dateStamp = "$mon-$mday-$year";

#find out who is running this process
my $who = `whoami`;
chomp $who;

#Get the list of directories
my @baseDirs = `find /usr/peoplesoft/$who/appserv/prcs/* \\( ! -name dir -prune \\) -type d -print`;

#for each dir arcvhive and delete folder from log_ouput
foreach my $baseDir (@baseDirs) {
chomp $baseDir;

#set the path to the directory that has the logs and the archive directory
my $logDir = "$baseDir/log_output";
my $logArchiveDir ="$baseDir/log_output_archive";

unless(-d $logArchiveDir){
mkdir $logArchiveDir or die "Couldn't create dir: [$logArchiveDir] ($!)";;
}

#archive then delete out put folders
system("/usr/bin/tar cvf - `/usr/bin/find $logDir/* -mtime +$numDays` | gzip > $logArchiveDir/log_output_$dateStamp.tar.gz");
system("/usr/bin/find $logDir/* -mtime +$numDays -exec rm -rf {} \\;");
system("/usr/bin/find $logArchiveDir/* -mtime +$numLongDays -exec rm -rf {} \\;");
}

Tuesday, July 8, 2008

Why its important to rotate logs.

Any of you who have been in the sysadmin business for more then a few days know how critical it is to rotate log files. When logs get to big your system will stop working. For example each file system has a maximum file size (http://www.novell.com/documentation/suse91/suselinux-adminguide/html/apas04.html#tab:maxsize) which if reached will cause problems. In the old days linux had a 2 gig ceiling and when your apache access log reached it apache would crash and not come back up. Some times worse.

Today I ran into a new one, in Solaris there is a limit to the number of sub directories that can be created. The magic number is none other than 32,767. We had a process that was storing log files for in there own sub directories. It had been doing this for multiple years and finally it had the lmit. We got this rather unhelp error, mkdir: Failed to make directory "test3"; Too many links.

The solution was rather simple. Tar up and archive the folders and then delete the originals. I set up a quick script to do this monthly and hopefully we will be all set. Going forward I would like to get a more robust solution in place like the standard logrotate. Dare to dream.