Home  >  Article  >  Database  >  Oracle 删除归档日志脚本

Oracle 删除归档日志脚本

WBOY
WBOYOriginal
2016-06-07 17:04:341371browse

归档日志记录着数据库的操作记录,是做数据恢复的依据,如果数据库开启了归档模式,那么就会产生大量的归档日志,当然如果有RMAN

归档日志记录着数据库的操作记录,是做数据恢复的依据,如果数据库开启了归档模式,那么就会产生大量的归档日志,当然如果有RMAN备份的话,可以在备份之后删除已经备份过的日志,如果是没有采用rman备份的话,就需要自己来删除这写归档日志。 下面的几个脚本就减轻了DBA的工作量。

Linux 平台:
0 2  * * * /home/Oracle/scripts/del_archive.sh > /home/oracle/scripts/del_archive.log

[oracle@hfcc-svr-newccsdb1 ~]$ more /home/oracle/scripts/del_archive.sh
#!/usr/bin/ksh
# create by tianlesoftware

export ORACLE_HOME=/dba/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl

export SHELL_DIR=/home/oracle/scripts

del_seq=`ls /u01/newccs_archive/|head -1|cut -f2 -d_`
echo $del_seq

max_sn=`cat /home/oracle/scripts/max_sn.log|awk '{print $1}'|grep ^[0-9]`
max_sn=`expr $max_sn - 5`
echo $max_sn

while [ $del_seq -lt $max_sn ]
do
  rm /u01/archive/1_"$del_seq"_692846987.dbf
  del_seq=`expr $del_seq + 1`
  echo $del_seq

done

或者用脚本:
del_arc.sh
find /u01/backups -mtime +10 -name "*.dbf" -exec rm -rf {} /;

Windows 平台:

del_arc_orcl.bat
forfiles /p d:/arc_orcl /m *.DBF /d -3 /c "cmd /c del @file"

将del_arc_orcl.bat 添加到计划任务即可.

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn