Managing Oracle Alert Log Files
#!/bin/ksh
# makes a dated copy of the alert log and clears out the original
date=`date +"%m%d%y"`
cp /oradata02/PROD/admin/PROD/bdump/alert_PROD.log /oradata02/PROD/admin/PROD/bdump/alert_PROD.log.$date
rm /oradata02/PROD/admin/PROD/bdump/alert_PROD.log
touch /oradata02/PROD/admin/PROD/bdump/alert_PROD.log
remove_old_files.bsh
#!/bin/bash
# Works for Oracle databases pre-11g
# 11g introduces universal diagnostic dest
function quit {
echo "${0} ORACLE_SID DAYS_OLD";
exit;
}
# Make Sure Oracle instance name is passed
if [ "" == "${1}" ]; then
quit;
fi;
# Make Sure the Days Old argument is passed
if [ "" == "${2}" ]; then
quit;
fi;
# Set the Environment
export ORACLE_SID=${1};
export DAYS_OLD=${2};
export ORAENV_ASK=NO;
. oraenv;
# Get the location for the bdump
bdump=`${ORACLE_HOME}/bin/sqlplus -s /nolog <<EOF
connect / as sysdba ;
set head off;
set feedback off;
set verify off;
select value from v\\$parameter where name='background_dump_dest';
exit;
EOF `
# Get the location for the udump
udump=`${ORACLE_HOME}/bin/sqlplus -s /nolog <<EOF
connect / as sysdba ;
set head off;
set feedback off;
set verify off;
select value from v\\$parameter where name='user_dump_dest';
exit;
EOF `
# Make sure the directories are valid and cleanup the files
if [ -d ${bdump} ] && [ -d ${udump} ] ; then
echo "Removing old files at `date +%Y%m%d%H%M` for ${ORACLE_SID}" ;
echo "Background Dump Before Cleanup `ls -l ${bdump} | wc -l`";
echo "User Dump Before Cleanup `ls -l ${udump} | wc -l`";
echo "Listener Log Dump Before Cleanup `ls -l ${ORACLE_HOME}/network/log | wc -l` ";
find ${bdump} -mtime +${DAYS_OLD} -name "*" -type f -exec rm {} \;
find ${udump} -mtime +${DAYS_OLD} -name "*" -type f -exec rm {} \;
find ${ORACLE_HOME}/network/log -mtime +${DAYS_OLD} -name "*" -type f -exec rm {} \;
echo "Background Dump After Cleanup `ls -l ${bdump} | wc -l`";
echo "User Dump After Cleanup `ls -l ${udump} | wc -l`";
echo "Listener Log Dump After Cleanup `ls -l ${ORACLE_HOME}/network/log | wc -l` ";
fi;