为了方便有效的清理冗余日志,将常规操作脚本化,支持linux环境下的10g/11gR1/11gR2
1 ----------------------ORACLE 10G DB环境
使用oracle用户执行
ps -ef | grep pmon |sort -r| grep -v grep | grep -v ASM| awk -F '_' '{print $3}'| while read SID
do
export ORACLE_SID=${SID}
V_VALUE1=`sqlplus -S /nolog <<EOF
connect /as sysdba
set heading off feedback off pagesize 0 verify off echo off;
select p.value from v\\$parameter p where p.NAME = 'background_dump_dest';
EOF`
V_VALUE2=`sqlplus -S /nolog <<EOF
connect /as sysdba
set heading off feedback off pagesize 0 verify off echo off;
select p.value from v\\$parameter p where p.NAME = 'user_dump_dest';
EOF`
V_VALUE3=`sqlplus -S /nolog <<EOF
connect /as sysdba
set heading off feedback off pagesize 0 verify off echo off;
select p.value from v\\$parameter p where p.NAME = 'core_dump_dest';
EOF`
NUM1=`ls $V_VALUE1 | wc -l`
NUM2=`ls $V_VALUE2 | wc -l`
NUM3=`ls $V_VALUE3 | wc -l`
echo 'Old Num1 = '${NUM1};
echo 'Old Num2 = '${NUM2};
echo 'Old Num3 = '${NUM3};
find $V_VALUE1 -name ${ORACLE_SID}_*.trc -type f -mtime +60 -exec rm -f {} \;
find $V_VALUE2 -name ${ORACLE_SID}_*.trc -type f -mtime +60 -exec rm -f {} \;
find $V_VALUE3 -name core_* -type d -mtime +60 -exec rm -rf {} \;
NUM1=`ls $V_VALUE1 | wc -l`
NUM2=`ls $V_VALUE2 | wc -l`
NUM3=`ls $V_VALUE3 | wc -l`
echo 'New Num1 = '${NUM1};
echo 'New Num2 = '${NUM2};
echo 'New Num3 = '${NUM3};
done
2 ----------------------ORACLE 11G DB环境
使用oracle用户执行
ps -ef | grep pmon |sort -r| grep -v grep | grep -v ASM| awk -F '_' '{print $3}'| while read SID
do
export ORACLE_SID=${SID}
V_VALUE=`sqlplus -S /nolog <<EOF
connect /as sysdba
set heading off feedback off pagesize 0 verify off echo off;
select p.value from v\\$parameter p where p.NAME = 'background_dump_dest';
EOF`
echo $V_VALUE;
find $V_VALUE -name cdmp_* -type d -exec rm -rf {} \;
find $V_VALUE -name *.trc -ctime +30 -type f -exec rm -f {} \;
find $V_VALUE -name *.trm -ctime +30 -type f -exec rm -f {} \;
done
3 ----------------------ORACLE 11G CRS
使用oracle用户执行
cat > $ORACLE_BASE/diag/tnslsnr/`hostname`/listener_`hostname`/trace/listener_`host
EOF
rm -f $ORACLE_BASE/diag/tnslsnr/`hostname`/listener_`hostname`/alert/log_*.xml
4 ----------------------ORACLE 11GR2 CRS
使用grid用户执行
BASE=`sqlplus -S / as sysdba <<EOF
set heading off feedback off pagesize 0 verify off echo off;
select p.value from v\\$parameter p where p.NAME = 'diagnostic_dest';
EOF`
cat > $BASE/diag/tnslsnr/`hostname`/listener/trace/listener.log <<EOF
EOF
cat > $GRID_HOME/log/diag/tnslsnr/`hostname`/listener_scan1/trace/listener_scan1.log
EOF
rm -f $BASE/diag/tnslsnr/`hostname`/listener/alert/log_*.xml
rm -f $GRID_HOME/log/diag/tnslsnr/`hostname`/listener_scan1/alert/log_*.xml
find $GRID_HOME/rdbms/audit -type f -name *ASM*.aud -mtime +60 -exec rm -rf {} \;