定時刪除bdump裡的trace檔案

perfychi發表於2012-11-27
[oracle@shanxi ORCL]$ cat /home/oracle/admin/del_bdump2.sh 
#!/bin/bash
#Author:chipengfei
#Date:2012-11-15

. /home/oracle/.bash_profile

log=/home/oracle/oracle_log/del_bdump2.log
flag=`ps -ef | grep ora_ | grep -v 'grep'`

if [ -z  "$flag" ] ; then
        exit
fi

echo ------------
now=`date "+%Y-%m-%d %H:%M:%S"`
echo "----------------------------$now-------------------------------" >> $log
bg_list=`ps -ef | grep -i ora_ | grep -v 'grep'  |  awk '{print $2}'`
filter=''
for i in $bg_list ; do
filter="${filter}|_${i}.trc"
done


filter2=`echo $filter | sed 's/^|//'`
cd $ORACLE_BASE/admin/$ORACLE_SID/bdump

ls  | grep '.trc' | egrep -v "${filter2}" >>  $log
ls  | grep '.trc' | egrep -v "${filter2}" | xargs -n 5 rm -rf 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27042095/viewspace-750058/,如需轉載,請註明出處,否則將追究法律責任。

相關文章