Linux Oracle DB log 清理
sid_list=`/bin/ps -ef |/bin/grep smon |/bin/grep -v grep | /bin/cut -f3 -d_`
host_name=`hostname`
cdate=`date +%Y_%m_%d_%H_%M_%S`
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/admin
#dumpfile tracefile incident listener
for sid in $sid_list;
do
export ORACLE_SID=$sid;
l_sid=`tr '[A-Z]' '[a-z]' <<<"$sid"`
u_sid=`tr '[a-z]' '[A-Z]' <<<"$sid"`
/usr/bin/find /oracle/admin/$sid/adump -mtime +7 -name "*.aud"|xargs rm -f
if [ $l_sid == $sid ];
then
/usr/bin/find /oracle/diag/rdbms/$l_sid/$l_sid/trace -mtime +3 -name "*.trc"|xargs rm -f
/usr/bin/find /oracle/diag/rdbms/$l_sid/$l_sid/trace -mtime +3 -name "*.trm"|xargs rm -f
/usr/bin/find /oracle/diag/rdbms/$l_sid/$l_sid/incident -mtime +3 -name "incdir*"|xargs rm -rf
/usr/bin/find /oracle/diag/rdbms/$l_sid/$l_sid/alert -mtime +3 -name "log*.xml"|xargs rm -rf
else
/usr/bin/find /oracle/diag/rdbms/$l_sid/$u_sid/trace -mtime +3 -name "*.trc"|xargs rm -f
/usr/bin/find /oracle/diag/rdbms/$l_sid/$u_sid/trace -mtime +3 -name "*.trm"|xargs rm -f
/usr/bin/find /oracle/diag/rdbms/$l_sid/$u_sid/incident -mtime +3 -name "incdir*"|xargs rm -rf
/usr/bin/find /oracle/diag/rdbms/$l_sid/$u_sid/alert -mtime +3 -name "log*.xml"|xargs rm -rf
fi
mv /oracle/diag/tnslsnr/$host_name/listener_$l_sid/alert/log.xml /oracle/diag/tnslsnr/$host_name/listener_$l_sid/alert/log_$cdate.xml
mv /oracle/diag/tnslsnr/$host_name/listener_$l_sid/trace/listener_$l_sid.log /oracle/diag/tnslsnr/$host_name/listener_$l_sid/trace/listener_$cdate.log
/usr/bin/find /oracle/diag/tnslsnr/$host_name/listener_$l_sid/alert/* -mtime +4 -name "log*.xml"|xargs rm -rf
/usr/bin/find /oracle/diag/tnslsnr/$host_name/listener_$l_sid/trace/* -mtime +4 -name "listener*.log"|xargs rm -f
/usr/bin/find /oracle/diag/tnslsnr/$host_name/listener_$l_sid/incident/* -mtime +3 -name "incdir*"|xargs rm -rf
done