#run the environment variable profile RUNDATE=`date "+%d%m%y at %H:%M:%S"` LOGFILE=/home/oracle/dbtest echo $ORACLE_HOME #--------Clean up audits---------- find $ORACLE_HOME/rdbms/audit -name "ora_*.aud" -mtime +365 -exec echo Removing File: \\c \; -exec ls -l {} \; -exec rm -f {} \; #-----Trim the listener logs to have 365 days log history-----------. cd $ORACLE_HOME/network/log export THE_DATE=$(date +"%m_%d_%Y") mv listener.log listener$THE_DATE.log touch $ORACLE_HOME/network/log/listener.log chmod 644 $ORACLE_HOME/network/log/listener.log find $ORACLE_HOME/network/log/listener* -mtime +365 -exec rm {} \; #-------Trim the alert log to have 365days log history-------------. LDATE=`date '+%Y-%m-%d-%H:%M'` cd /opt/oracle/product/10.2.0/admin/PHYINVT/bdump mv alert_$ORACLE_SID.log alert_$ORACLE_SID."$LDATE" touch alert_$ORACLE_SID.log chmod 0640 alert_$ORACLE_SID.log find /opt/oracle/product/10.2.0/admin/PHYINVT/bdump -name "alert_*" -mtime +365 -exec echo Removing File: \\c \; -exec ls -l {} \; -exec rm -f {} \; #--------------------- Clean Backup Logs------------------------- #find /home/oracle/dba/scripts -name \*.log -mtime +365 -exec rm {} \; #-----------------------Clean trc and dump file in udump,cdump & bdump---------------- #find $ORACLE_HOME/SID/bdump* -mtime +365 -exec rm {} \; find /opt/oracle/product/10.2.0/admin/PHYINVT/bdump -name \*.trc -mtime +365 -exec echo Removing File: \\c \; -exec ls -l {} \; -exec rm -f {} \; find /opt/oracle/product/10.2.0/admin/PHYINVT/cdump -name \*.trc -mtime +365 -exec echo Removing File: \\c \; -exec ls -l {} \; -exec rm -f {} \; find /opt/oracle/product/10.2.0/admin/PHYINVT/udump -name \*.trc -mtime +365 -exec echo Removing File: \\c \; -exec ls -l {} \; -exec rm -f {} \; > $LOGFILE/mail.log mail -s "Status of $ORACLE_SID Old trace file successfully purging on $RUNDATE " abc@xyz.com < $LOGFILE/mail.log exit;