FAQ
Oracle 10.2.0.3.0 on Windows Server 2003 sp2.

How do you truncate the listener log file without bouncing the listener?

I know how to do this on UNIX, but when I try "echo > listener.log" I get "cannot access the file because it is being used by another process". The other option, appears to be to use the lsnrctl "set log" command followed by "save config", but, according to MOS, this may crash the listener.

Any other options?

Thanks,
Peter Schauss

Search Discussions

  • Jay Hostetter at Jul 26, 2011 at 8:47 pm
    I use "set log_file", but I don't save the config.

    lsnrctl
    set log_file listener_temp.log
    then I rename listener.log to something else (listener_20110725.log)
    set log_file listener.log
    If you have admin restrictions on, you'll need to change the listener.ora
    and reload it first.

    Jay
    On Tue, Jul 26, 2011 at 4:40 PM, Schauss, Peter (ESS) wrote:

    Oracle 10.2.0.3.0 on Windows Server 2003 sp2.

    How do you truncate the listener log file without bouncing the listener?

    I know how to do this on UNIX, but when I try "echo > listener.log" I get
    "cannot access the file because it is being used by another process". The
    other option, appears to be to use the lsnrctl "set log" command followed by
    "save config", but, according to MOS, this may crash the listener.

    Any other options?

    Thanks,
    Peter Schauss
    --
    http://www.freelists.org/webpage/oracle-l

    --
    http://www.freelists.org/webpage/oracle-l
  • Alexander Feinstein at Jul 26, 2011 at 10:56 pm
    Here is simplified version of what I use on Windows 2008 R2

    _at_echo off
    rem Name lsnrmnt.cmd
    rem Purpose: ORACLE LISTENER services maintanance
    rem Usage: lsnrmnt.cmd [listener_name
    rem
    rem Parms:
    rem 1 - listener name (default listener)
    rem

    setlocal enableextensions enabledelayedexpansion

    if "%1" == "" (
    set LSNR_SID=listener
    ) else (
    set LSNR_SID=%1
    )

    call e:\oracle\admin\common\sh\oraenv.cmd %LSNR_SID%

    set NET_LOG=%OA%\log

    for /F "tokens=1-4 delims=/ " %%o in ("%DATE%") do (

    set DW=%%o
    set MM=%%p
    set DD=%%q
    set YY=%%r

    )
    for /F "tokens=1-5 delims=.:" %%s in ("%TIME%") do (

    set HH=%%s
    set MI=%%t
    set SS=%%u

    )
    set CURR_DATE=%YY%%MM%%DD%%HH%%MI%%SS%
    set CURR_DATE=%CURR_DATE: =0%

    (echo set current_listener %LSNR_SID%
    echo set log_file %NET_LOG%\%LSNR_SID%.log.2
    echo exit
    ) | %OH%\bin\lsnrctl
    rename %NET_LOG%\%LSNR_SID%.log %LSNR_SID%.log.1
    (echo set current_listener %LSNR_SID%
    echo set log_file %NET_LOG%\%LSNR_SID%.log
    echo exit
    ) | %OH%\bin\lsnrctl
    copy %NET_LOG%\%LSNR_SID%.log.1 + %NET_LOG%\%LSNR_SID%.log.2
    %NET_LOG%\%LSNR_SID%_%CURR_DAY%.log
    del %NET_LOG%\%LSNR_SID%.log.1
    del %NET_LOG%\%LSNR_SID%.log.2

    endlocal

    Alex.
    On Tue, Jul 26, 2011 at 1:47 PM, Jay Hostetter wrote:

    I use "set log_file", but I don't save the config.

    lsnrctl
    set log_file listener_temp.log
    then I rename listener.log to something else (listener_20110725.log)
    set log_file listener.log
    If you have admin restrictions on, you'll need to change the listener.ora
    and reload it first.

    Jay

    On Tue, Jul 26, 2011 at 4:40 PM, Schauss, Peter (ESS) <
    peter.schauss_at_ngc.com> wrote:
    Oracle 10.2.0.3.0 on Windows Server 2003 sp2.

    How do you truncate the listener log file without bouncing the listener?

    I know how to do this on UNIX, but when I try "echo > listener.log" I get
    "cannot access the file because it is being used by another process". The
    other option, appears to be to use the lsnrctl "set log" command followed by
    "save config", but, according to MOS, this may crash the listener.

    Any other options?

    Thanks,
    Peter Schauss
    --
    http://www.freelists.org/webpage/oracle-l

    --
    http://www.freelists.org/webpage/oracle-l
  • Powell, Mark at Jul 27, 2011 at 4:49 pm


    Why not just turn off logging, delete or reduce the file size, and then re-start logging?

    set log_status off

    -----Original Message-----
    From: oracle-l-bounce_at_freelists.org On Behalf Of Schauss, Peter (ESS)
    Sent: Tuesday, July 26, 2011 4:40 PM
    To: oracle-l@freelists.org
    Subject: truncating listener.log on Windows

    Oracle 10.2.0.3.0 on Windows Server 2003 sp2.

    How do you truncate the listener log file without bouncing the listener?

    I know how to do this on UNIX, but when I try "echo > listener.log" I get "cannot access the file because it is being used by another process". The other option, appears to be to use the lsnrctl "set log" command followed by "save config", but, according to MOS, this may crash the listener.

    Any other options?

    Thanks,
    Peter Schauss
    --
    http://www.freelists.org/webpage/oracle-l

    --
    http://www.freelists.org/webpage/oracle-l
  • Niall Litchfield at Jul 27, 2011 at 5:03 pm
    Alex's example has the advantage of preserving the entire log stream should
    your auditors require it, mine will lose some small amount of data, but that
    maybe acceptable, but I agree if the requirement is to periodically
    truncate, like the *nix example, then not logging in the first place seems
    sensible.

    On 27 Jul 2011 17:53, "Powell, Mark" wrote:

    Why not just turn off logging, delete or reduce the file size, and then
    re-start logging?

    set log_status off

    -----Original Message-----
    From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.o...

    --
    http://www.freelists.org/webpage/oracle-l
  • Marco Gralike at Jul 27, 2011 at 5:17 pm
    Disabling temporarily the logging is one, if you want to do something like "echo >" you could also use the unxutils tool set from sourceforge.net. I like it, if not only for the grep etc, because its a "standalone" utility set. No install or registry entry needed. See http://unxutils.sourceforge.net/

    From: "Schauss, Peter (ESS)" >
    Reply-To: "peter.schauss_at_ngc.com" >
    Date: Tue, 26 Jul 2011 22:40:26 +0200
    To: Oracle-L >
    Subject: truncating listener.log on Windows

    Oracle 10.2.0.3.0 on Windows Server 2003 sp2.

    How do you truncate the listener log file without bouncing the listener?

    I know how to do this on UNIX, but when I try "echo > listener.log" I get "cannot access the file because it is being used by another process". The other option, appears to be to use the lsnrctl "set log" command followed by "save config", but, according to MOS, this may crash the listener.

    Any other options?

    Thanks,
    Peter Schauss

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouporacle-l @
categoriesoracle
postedJul 26, '11 at 8:40p
activeJul 27, '11 at 5:17p
posts6
users6
websiteoracle.com

People

Translate

site design / logo © 2022 Grokbase