DBA Tips Archive for Oracle


Recycling the listener.log File

by Jeff Hunter, Sr. Database Administrator

As the listener.log file grows, the DBA will want to either remove or rename this log file. If you have ever tried to remove or rename the listener.log file on Windows while the TNS listener process was running you will quickly notice that Windows holds a lock on this file and returns an error:

C:\> del C:\oracle\ora92\network\log\listener.log
The process cannot access the file because it is being used by another process.
Most DBAs simply stop the TNS listener process, rename (or remove) the file, then restart the TNS listener process. This can, however, cause potention connection errors for users that are attempting to connect while the listener process is down.

Even under UNIX, problems exist when attempting to rename the listener.log file while the TNS listener process is running. Just like under Windows, the Oracle TNS listener process holds an open handle to the file. Under UNIX, you CAN remove the file, but Oracle will not re-create the file when it attempts to write to it again. The TNS listener will need to be stopped and restarted in order for it to create the new listener.log file.

Well, here is a solution for renaming (or removing) the listener.log file without having to stop and start the TNS listener process under either Windows or UNIX:

C:\> cd \oracle\ora92\network\log
C:\oracle\ora92\network\log> lsnrctl set log_status off
C:\oracle\ora92\network\log> rename listener.log listener.old
C:\oracle\ora92\network\log> lsnrctl set log_status on

% cd /u01/app/oracle/product/9.2.0/network/log
% lsnrctl set log_status off
% mv listener.log listener.old
% lsnrctl set log_status on

Copyright (c) 1998-2018 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Tuesday, 19-Apr-2005 00:00:00 EDT
Page Count: 72877