Recycle Listener Log Online

There are many times when we see Listener including SCAN listeners log is growing very big. So we need purge it periodically. We can stop listener, then rename/delete/zip the listener log, then start the listener again.  But It is not a good practice to stop listener, because it will make client not be able to connect to database.

Here is a simple way to demonstrate how to purge listener log online:

$ lsnrctl
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-SEP-2016 10:17:10
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.

LSNRCTL> set
The following operations are available after set
An asterisk (*) denotes a modifier or extended command:
rawmode displaymode
trc_file trc_directory
trc_level log_file
log_directory log_status
current_listener inbound_connect_timeout
startup_waittime save_config_on_stop
dynamic_registration enable_global_dynamic_endpoint
connection_rate_limit valid_node_checking_registration
registration_invited_nodes registration_excluded_nodes

LSNRCTL> set current_listener listener
Current Listener is listener

LSNRCTL> show log_status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
listener parameter "log_status" set to ON
The command completed successfully

LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
listener parameter "log_status" set to OFF
The command completed successfully
LSNRCTL> exit


$ cd /u01/app/grid/diag/tnslsnr/racnode1/listener/trace
$ ls -ltr
total 223388
...
..
.
-rw-r----- 1 grid oinstall 146333508 Sep 21 10:17 listener.log
...
..
.
$cp listener.log listener_old.log
$cat /dev/null > listener.log

$ lsnrctl
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 21-SEP-2016 10:17:52
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.

LSNRCTL> set current_listener listener
Current Listener is listener
LSNRCTL> show log_status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
listener parameter "log_status" set to OFF
The command completed successfully


LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
listener parameter "log_status" set to ON
The command completed successfully
LSNRCTL> exit


$ ls -ltr
total 224816
...
..
.
-rw-r----- 1 grid oinstall 146333508 Sep 21 10:17 listener_old.log
-rw-r----- 1 grid oinstall 2834 Sep 21 10:18 listener.log
...
..
.
Advertisements
This entry was posted in GI and RAC, SQL Net and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s