#!/bin/bash
archivedir=/parablu/archive/tomcat-pcb1/catalina
logdir=/var/lib/tomcat-pcb1/logs
numfiles=5

gzip /var/lib/tomcat-pcb1/logs/catalina.out-*
sleep 2s
echo "running tomcat-pcb1 archival script"
if [ ! -d "$archivedir" ];
then
        mkdir -p $archivedir 2>&1
fi

cd $logdir
mv *.gz $archivedir

sleep 2
cd $archivedir
ls -t | sed -e "1, $numfiles d" | xargs -d '\n' rm
