ORACLE 11 GB Single Instance Disk File System DG archive log deletion script based on red hat linux 5.3X86 64BIT

Source: Internet
Author: User

Recently deleted the archive log of DG,

[oracle@.local logs]crontab -l* 8 * * * sh /home/oracle/dbscripts/del_arc.sh
 
This script calls the three scripts that generate the delete verification respectively.
cat del_arc.sh#! /bin/bashsource /home/oracle/.bash_profilesh /home/oracle/dbscripts/build_del_archivelog.sh >> /home/oracle/dbscripts/del_arch`date +%F_%H`.shsleep 5sh /home/oracle/dbscripts/del_arch`date +%F_%H`.sh >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.logsleep 5sh /home/oracle/dbscripts/crosscheck_archivelog.sh >> /home/oracle/dbscripts/logs/cross_check`date +%F_%H`.log

First look at the generated

cat build_del_archivelog.sh sqlplus -s shark/235619<<EOFset heading  offset linesize 1000set echo offset feedback offset timing  offset termout onset trimout offset trimspool onset newpage noneselect 'rm -f '||name  from  v\$archived_log where applied='YES' and deleted='NO' and completion_time < trunc(sysdate);EOF


It is mainly used to generate archive logs for physically deleting applications and obtain them from V $ archived_log. Note that the NAME in the ASM disk management does not contain the path.

In addition, the distance between each line generated is too large. Please advise.


Generated Delete script

]head del_arch2014-05-07_08.sh rm -f /arch_backup/1_24144_831167377.log                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                rm -f /arch_backup/2_22765_831167377.log       


That is, Y's line spacing is too large.

]cat crosscheck_archivelog.sh #! /bin/bashsource /home/oracle/.bash_profileexec >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.log$ORACLE_HOME/bin/rman target / <<EOFcrosscheck archivelog all;delete noprompt expired archivelog all;#delete noprompt archivelog until time 'sysdate-1';exit;EOF

This is the final script for validation! We can see from the annotations that we used to delete archived logs.

This check script is mainly used to clear the archive information. If the information is stored in the control file, DG cannot be deleted.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.