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
$ORACLE_HOME/diag/rdbms/<database>/<sid>/trace/alert_.log
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 { compress rotate 4 weekly 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 { compress rotate 4 weekly create 640 oracle oinstall prerotate su – oracle "lsnrctl set Log_status off" endscript postrotate su – oracle "lsnrctl set Log_status on" endscript } |







I learned a lot from this post, much appreciated!
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
… [Trackback]…
[...] Read More Infos here: mylinuxplace.com/database-tips/rotate-oracle-logs/ [...]…
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 {
compress
rotate 4
weekly
create 640 oracle oinstall
}
yes you can do it in this way
more