[Using Sakai] TIP for *nix users: keeping and time-stamping catalina.out logfiles

will at serensoft.com will at serensoft.com
Mon Dec 21 10:57:32 PST 2009


Here's a trick we use at Serensoft to have one time-stamped catalina.out
logfile per tomcat-launch on a *nix Sakai server:

#!/bin/sh
# Sakai log-rotating start-up wrapper from Serensoft.com

TODAY=`date +%Y/%m/%d`;
NOW=`date +%T`
LOGDIR=rotate/$TODAY
LOGFILE=catalina.out

mkdir -p $CATALINA_HOME/logs/$LOGDIR

# remove original (the 'other' hard link)
/bin/rm -f $CATALINA_HOME/logs/$LOGFILE
# create new logfile
touch $CATALINA_HOME/logs/$LOGFILE

# make a HARD link (the 'main' link, from our perspective)
# to tomcat/logs/calendar/YYYY/MM/DD/HH:MM:SS.catalina.log
(cd $CATALINA_HOME/logs; ln $LOGFILE $LOGDIR/$NOW.$LOGFILE)

# now for the "real" startup script:
$CATALINA_HOME/bin/startup.sh
# Follow the startup logs:
tail -f $CATALINA_HOME/logs/$LOGFILE

And that's all there is to it.

Each HH:MM:SS.catalina.log is actually the full, original logfile; the
catalina.out instance that Sakai dumps to is one of two hard links to the
same file -- and that's the instance that gets blown away on every restart,
so that it points to the new logfile instance. (Here's the single caveat:
you'll lose your first, original catalina.out if you don't back it up before
deploying this script.)

~/tomcat/logs> ls -1 rotate/2009/12/03
08:41:22.catalina.log
10:02:02.catalina.log
19:25:37.catalina.log

So here you can see that, for example, on December 3rd, we bounced this
particular Sakai three times. Name of the file is the timestamp of start-up,
of course. Very convenient for anthropology or forensics (or morbid
curiosity)!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-user/attachments/20091221/5532cde8/attachment.html 


More information about the sakai-user mailing list