由于ARCHIVE LOG 增长快,不得不每天要删除一部分已RECVOERY
的ARCHIVE LOG.
因此,写了一个脚本来执行。
此文档仅供大家参考 , 需根据自己的实际情况进行修改。
作者: jacky2000
2003-03-26
用来删除多余的archive log 文件 , 只保留最近10个archive log
****** file1: st.sh ******
//主执行文件
===================================================================================
sqlplus '/as sysdba' @a.sql
sed 's/ //g' logid.txt >3
sed '1d' 3 >logid.txt
ls /exp/arch/*.dbf |awk '{print substr($1,13,length($1)-16)}' >arch.txt
cat arch.txt |sort -n >tmp.txt
mv tmp.txt arch.txt
low_n=`head -n 1 arch.txt`
high_n=`head -n 1 logid.txt`
let mm=$high_n-$low_n
if [ "$mm" -gt "10" ]; then
echo " $mm >0 , Delete start ...."
sh del_arch.sh $high_n $low_n
else
echo " $mm < 0 , No file deleted !"
fi
rm 3
rm arch.txt
rm logid.txt
exit
=====================================================================================
****** file2: a.sql ******
//得到倒数第11个 logical log 的id
=====================================================================================
set heading off;
set feedback off;
spool logid.txt ;
select max(sequence#)-10 from v$log_history;
spool off;
exit
=====================================================================================
****** file3: del_arch.sh ******
//用来删除符合条件archive log
=====================================================================================
arch_n=$1
let tmp_n=arch_n
while [ "$tmp_n" -ge "$2" ]
do
rm /exp/arch/1_${tmp_n}.dbf
echo "1_${tmp_n}.dbf , delete OK !"
let tmp_n=tmp_n-1
done
=====================================================================================
的ARCHIVE LOG.
因此,写了一个脚本来执行。
此文档仅供大家参考 , 需根据自己的实际情况进行修改。
作者: jacky2000
2003-03-26
用来删除多余的archive log 文件 , 只保留最近10个archive log
****** file1: st.sh ******
//主执行文件
===================================================================================
sqlplus '/as sysdba' @a.sql
sed 's/ //g' logid.txt >3
sed '1d' 3 >logid.txt
ls /exp/arch/*.dbf |awk '{print substr($1,13,length($1)-16)}' >arch.txt
cat arch.txt |sort -n >tmp.txt
mv tmp.txt arch.txt
low_n=`head -n 1 arch.txt`
high_n=`head -n 1 logid.txt`
let mm=$high_n-$low_n
if [ "$mm" -gt "10" ]; then
echo " $mm >0 , Delete start ...."
sh del_arch.sh $high_n $low_n
else
echo " $mm < 0 , No file deleted !"
fi
rm 3
rm arch.txt
rm logid.txt
exit
=====================================================================================
****** file2: a.sql ******
//得到倒数第11个 logical log 的id
=====================================================================================
set heading off;
set feedback off;
spool logid.txt ;
select max(sequence#)-10 from v$log_history;
spool off;
exit
=====================================================================================
****** file3: del_arch.sh ******
//用来删除符合条件archive log
=====================================================================================
arch_n=$1
let tmp_n=arch_n
while [ "$tmp_n" -ge "$2" ]
do
rm /exp/arch/1_${tmp_n}.dbf
echo "1_${tmp_n}.dbf , delete OK !"
let tmp_n=tmp_n-1
done
=====================================================================================
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18234/viewspace-629138/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18234/viewspace-629138/