ITPub博客

首页 > Linux操作系统 > Linux操作系统 > DATAGUARD定期删除归档日志脚本

DATAGUARD定期删除归档日志脚本

原创 Linux操作系统 作者:lxq1985 时间:2010-02-22 14:21:34 0 删除 编辑

#!/bin/sh
applied_days=2
cat /dev/null>applied_arch.lst
sqlplus -s "/ as sysdba"</dev/null
set feedback off
set pages 0
set head off
set timing off
set echo off
spool applied_arch.lst
select 'rm -f '||name from v\$archived_log
where DEST_ID=2 and name like '%.dbf'
and SEQUENCE#<(select max(SEQUENCE#) from v\$archived_log where applied='YES')
and COMPLETION_TIME<=sysdate-${applied_days};
spool off;
exit
EOF

## Exec the shell
cat /dev/null>applied_arch.sh
cat applied_arch.lst |grep -v spooling>applied_arch.sh
chmod u+x applied_arch.sh
sh applied_arch.sh
chmod -x applied_arch.sh
mv applied_arch.sh ./log/rm_appl_arc_`date +"%Y%m%d%H%M"`.log

rm -f applied_arch.lst

##remove expired archive log from database
/data/oracle9/product/9.2.0/bin/rman target / nocatalog<crosscheck archivelog all;               
delete noprompt expired archivelog all;
exit
EOF

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13636837/viewspace-627484/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-12-26

  • 博文量
    29
  • 访问量
    46912