Archiving/Purge listener logfile

The listener log file can grow over time and archive the listener log file one can’t move the file and create a new file using touch as the listener has a open/active file handle to log file causes the listener to no longer update the log file. So work around this issue one would need to do the following steps to archive the file and so listener can still continue writing to the log file.

# change directory to location where the listener log file resides
$ cd $ORACLE_HOME/network/log
# display inode of the file to show it doesn’t change during echo
$ ls -i listener.log
220993 listener.log
# copy the listener log file
$ cp -p listener.log listener.log.1
# erase contents of the current log file
$ echo “” > listener.log
# inode is the same as before which shows the listener will continue to able to write to this file
$ ls -i listener.log
220993 listener.log

To purge the listener log file without restarting the listener
$ cd $ORACLE_HOME/network/log
$ echo “” > listener.log

One comment

  1. Other way ::
    cd $listner_dir

    date > listener.lst

    lsnrctl set log_file listener2${_TimeStamp}> /dev/null 2>&1

    mv $listner_log_file $listner_log_file.${_TimeStamp} > /dev/null 2>&1

    lsnrctl set log_file $listner_log_file > /dev/null 2>&1

    rm listener2${_TimeStamp}.log> /dev/null 2>&1

Leave a Reply