Three ways To trim Alert logs in oracle



Oracle Alert logs contain chronological list of events in a database , there are times when you need to clean some contents of an alert log or to move it some where , to free up space , if you need more on Alert log please check ALert log. 

Here are three different ways to clean contents of Alert logs in Linux :-


1.Using ADRCI utility

ADRCI utility can be used to purge Alert logs and trace files , for example :


Deleting previous ALERT files created before 3600 minutes(1 day) in specified home directory:
  steps :-

    1. first show a list of home directories from which to delete logs

     2. set the directory from which you want to delete the logs
      

     3. run purge command 

2. CLEAR ALERT LOG FILE AND TRACE FILES MANUALLY

we may need to clear alert log file contents manually  in the following cases:
1.When size of Alert log size gets larger 
If alert log file gets too large you have different  options to handle it:    
A)Trim some contents from alert log file 
If you want to keep most recent entries in the alert log just trim obsolete records off the alert log file
      =>   Paste the last certain number of lines of the alert log onto a second file

   
=>  Copy the transitional file back to the alert log with force option



B) Clear all contents from the alert log file  

Whenever you want to clear alert log in a hurry, you can empty all content of alert  log
  Copy the alert log if you need for troubleshooting purpose
$ cp alert_vmsdb.log alert_vms.log.bak
Clear the log file(different options):
    i) $ cat /dev/null > alert_vmsdb.log1954398
    ii) $echo ""  > alert_vmsdb.log
    iii) truncate -s 0 alert_vmsdb.log
     vi) true > alert_vmsdb.log
C) Delete/remove the alert log file totally (oracle will create it again when needed) 



Alert Logs in Oracle

what are alert log files in oracle?

Is a chronological log of messages and errors written out by an Oracle Database
Typical messages found in this file is:
  • Database startup, shutdown
  •  Log switches, all ORA errors,
  •  Alter system command,  
  •  DB structure changes like renaming,
  • Adding log files , archive generation info. etc.
Alert log file contains error message only in brief, but it will point to a file which will have more information about the error i.e. trace file.

Location of Alert Log

 There are different ways to get location of alert log files:
    1. ORACLE_BASE
    • The default location for oracle alert log file is $ORACLE_BASE/diag directory
   2. Dynamic Performance View v$diag_info
         • Select name , value from v$diag_info;
 3. Oracle database parameter background_dump_dest
                   

                            
                4.   ADRCI / Automatic Automatic diagnostic repository command interpreter





Thanks , Dereje Balcha