I am interested in catalina.out log file rotation, I have an application where logging to catalina.out is very huge, say 0.5 MB / sec.

So I have written one script to handle this which is shown below.

 

# crontab -l | grep catalina

0,30 * * * * bash /catalina_log_handler.sh  >/dev/null 2>&1

 

# more /catalina_log_handler.sh

#!/bin/sh

CATLOC=/bin/cat

SEDLOC=/usr/bin/sed

$CATLOC /catalina.out >> /catalina_backup.out à take a backup and then handle this file rotation using logadm

$SEDLOC ” catalina.out > catalina.out à Empty this file

 

There are two cases here

 

1.)     The below is normal behavior where not much logging

# ls -ltrh catalina*

-rw-r—–   1 ems      ems          15K Jan 31 12:07 catalina.2012-01-31.log

-rw-r—–   1 ems      ems         3.9K Feb  1 06:26 catalina.2012-02-01.log

-rw-r—–   1 ems      ems         345K Feb  1 06:45 catalina.out

-rw-r–r–   1 root     root         14M Feb  1 07:00 catalina_backup.out

 

2.)    The below is heavy logging behavior

# ls -ltrh catalina*

-rw-r—–   1 ems      ems         4.2K Jan 28 22:14 catalina.2012-01-28.log à why I am seeing catalina file with date, have the same content as catalina.out

-rw-r—–   1 ems      ems          362 Jan 30 06:30 catalina.2012-01-30.log

-rw-r—–   1 ems      ems          10M Jan 30 14:43 catalina.out.2

-rw-r–r–   1 root     root        1.7M Jan 30 17:00 catalina_backup.out.9.gz

-rw-r–r–   1 root     root        1.6M Jan 30 20:00 catalina_backup.out.8.gz

-rw-r–r–   1 root     root        1.6M Jan 30 23:00 catalina_backup.out.7.gz

-rw-r–r–   1 root     root        1.6M Jan 31 02:00 catalina_backup.out.6.gz

-rw-r—–   1 ems      ems         113M Jan 31 03:30 catalina.out.3

-rw-r–r–   1 root     root        1.8M Jan 31 06:00 catalina_backup.out.5.gz

-rw-r—–   1 ems      ems         6.2M Jan 31 10:04 catalina.out

-rw-r—–   1 ems      ems         4.5K Jan 31 10:04 catalina.2012-01-31.log

-rw-r–r–   1 root     root        1.8M Jan 31 10:30 catalina_backup.out.4.gz

-rw-r–r–   1 root     root        1.8M Jan 31 15:00 catalina_backup.out.3.gz

-rw-r–r–   1 root     root        1.8M Jan 31 19:30 catalina_backup.out.2.gz

-rw-r–r–   1 root     root        1.8M Feb  1 00:00 catalina_backup.out.1.gz

-rw-r–r–   1 root     root         12M Feb  1 01:00 catalina_backup.out

-rw-r—–   1 ems      ems          12M Feb  1 01:12 catalina.out.1 à why this is latest file ? Is this because of huge logging, Can I disable default catalina.out rotation so that my script will take care of moving the content from catalina.out to catalina_backup.out…

Leave a comment

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam

Hit Counter provided by dental implants orange county