Recycle Listener Logs Online

It is a good practice to recycle listener logs which grows in size day by day.

The listener logs including SCAN listeners are growing very fast and big. So we need purge them periodically. We can stop listener, rename/delete/zip the listener logs, but it is not a good practice to stop listener at any time, because it will impact the business.

Here is a simple way to purge listener logs 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
...
..
.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.