Great Tips for Growing Listener Log Files!!
We face a number of short-term yet frustrating issues when our listener log files grow beyond a certain size. It is advised to recycle Oracle log file when the size limit reaches 30MB but this can vary based on your application. In this article we will discuss some amazing tips to handle the growth of your listener log files.
When the listner log file grows beyond size then most database administrators recycle the listener.log file by removing or renaming the log file. One option to recycle your listener.log file is to first stop the listener, then renaming the listener log file to the name of the backup file and then starting the listener.
You must have experienced that when you attempt to clear the listener.log file then Windows holds a lock on the file. For this purpose they have to stop and then start the TNS listener process. Below command can be used to rename or remove the listener log file without the need to stop and then start the TNS listener process under either Windows. You will have to run these commands from your %ORACLE_HOME%\network\admin directory.
LSNRCTL SET LOG_STATUS OFF RENAME LISTENER.LOG LISTNER.OLD LSNRCTL SET LOG_STATUS ON
You can use below korn shell script (ksh) to check for the listener.log file size. You can put the script on the crontab and then need not to worry about it. Basically this script works by determining the size of your listerner log file. If it has reached a specific size then it renames the listener log file to a file with .bak extension and then creates a new listener.log file. cat /dev/null > listener.log command can be used to truncate the listener.log without stopping the listener. However this command will not erase the logfile and make it empty only and the flow of information will not be interrupted because it maintains the same inode value.
#!/USR/BIN/KSH
ENV_FILE=${1}
IF [ ! -F ${ENV_FILE} ] THEN /USR/BIN/ECHO “SORRY THE ${ENV_FILE} FILE DOES NOT EXIST.” EXIT 2 FI
. ${ENV_FILE}
MAX_SIZE=30000000 FILE=LISTENER.LOG FILE_PATH=$ORACLE_HOME/NETWORK/LOG/
SIZE=`LS -L $FILE_PATH/$FILE AWK ‘{ PRINT $5;}'`
IF [ $SIZE -GT $MAX_SIZE ] THEN CP $FILE_PATH/$FILE $FILE_PATH/$FILE.BAK CAT /DEV/NULL > $FILE_PATH/$FILE
No comments:
Post a Comment