Wednesday, May 28, 2014

How to check if Log Rotate is working fine?


Log rotate is used to do house keeping of log files in unix servers. Setting up log rotate needs root user privileges.

There are some environments where oracle DBA's will have root access privileges. Please check below to find if log rotate is working good or not.

**************************************** Step By Step Procedure ******************************************************

#########################################
# 1) Check Log Rotate Script
#########################################

Here we have a file called "listenerlogs" where compress of listener logs are carried out.

cd /etc/logrotate.d

[oracle@host01 logrotate.d]$ more listenerlogs
# Node Listener tracelog
/u01/app/oracle/diag/tnslsnr/host01/listener/trace/listener.log {
weekly
compress
rotate 4
notifempty
missingok
copytruncate
nocreate
}
[oracle@host01 logrotate.d]$

=====================================================================================================================
From above file, we can see that, every week listener.log file will be rotated and it will keep last 4 files
=====================================================================================================================

#########################################
# 2) Check Log files
#########################################

[oracle@host01 logrotate.d]$ ls -ltr /u01/app/oracle/diag/tnslsnr/host01/listener/trace/
total 1620
-rw-r----- 1 oracle oinstall   61879 Apr 27 03:31 listener.log-20140427.gz
-rw-r----- 1 oracle oinstall   63278 May  4 03:17 listener.log-20140504.gz
-rw-r----- 1 oracle oinstall   78429 May 11 03:46 listener.log-20140511.gz
-rw-r----- 1 oracle oinstall   99425 May 18 03:34 listener.log-20140518.gz
-rw-r----- 1 oracle oinstall 1339839 May 20 12:24 listener.log
[oracle@host01 logrotate.d]$ 

=====================================================================================================================
From above output you can see that log files are zipped on a weekly basis, so log rotate is working.
=====================================================================================================================

No comments: