Rotate Oracle logs

Oracle database logs doesn’t rotate by it self , and as time goes by, your
server may hold logs that are too big to read and takes too much storage space .
this can get your server to a maximum capacity , and in some cases crush your server .

The best thing i found is to use logrotate to handle this rotations .
there are 2 files that needs to be rotate ( depend on your infrastructure ) this files
are alert log and listener log . both can grow to unlimited size .
Create a new logrotate rule by edit a files
/etc/logrotate.d/oracle-alert and /etc/logrotate.d/oracle-listener
the oracle-alert file should point to the alert log usualy located under
here is an example of oracle-alert , that will rotate weekly and store for 4 files back
also it will compress that backups and create a new file with the correct permissions .
* note that Oracle will create a new alert log ,if the file is missing, upon next event

/opt/app/DB/diag/rdbms/example/example1/trace/alert_example1.log {
rotate 4
create 640 oracle oinstall


the next thing to handle is the listener , now the listener log cannot be remove just like that
if you do so , the listener would stop logging into that file . solving it with a special
commands that restart just the loger of the listener .
the location of the listener log is under $ORACLE_HOME/diag/tnslsnr/<database>/listener/trace/listener.log
This example shows how to weekly rotate and compress

/opt/app/DB/diag/tnslsnr/example/listener/trace/listener.log {
rotate 4
create 640 oracle oinstall
su – oracle "lsnrctl set Log_status off"
su – oracle "lsnrctl set Log_status on"
  1. Margaret Machine

    I learned a lot from this post, much appreciated! :)

  2. I have win 7 on one machine & ubuntu on another. My question is how would I setup a multi drive system & have ubuntu on it also. I do have 3 hard drives but I want a start up menu when I start the computor and choose between operating systems. Any reccomands?

    • I dont see what dual boot got to do with Oracle logs
      as a suggestion , you should ask your question in Ubuntu forum,
      or just google for it

  3. URL - trackback on July 31, 2012 at 12:53 pm
  4. I have multiple alert logs to rotate.. do I need to add multiple files or can I do it in one like below.

    /u01/oracle/diag/rdbms/emgprd/emgprd/trace/alert_emgprd.log /u01/oracle/diag/rdbms/wrm92prd/wrm92prd/trace/alert_wrm92prd.log {
    rotate 4
    create 640 oracle oinstall

  5. more

  6. yyagol, can you please brief me what exactly needs to be done with this script, as to where and how we should run this,like do we create a .bat file with this or wht… your patience and reply will be highly expected and appreciated

  7. Hi , its written in the post at the beginning .
    just place the file in the correct place and let logrotate pick it up from there .

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Trackbacks and Pingbacks:

  • URL - Trackback on 2012/07/31/ 12:53