定时执行脚本:
cleanarclog.sh
#!/bin/bash
oracle_sid=mdspdb
oracle_home="/opt/oracle/product/11g/db"
ps -ef | grep oracle | grep -w "ora_lgwr_${oracle_sid}" >& /dev/null
if [ $? -ne 0 ]
then
exit 0
fi
source $HOME/.bash_profile ## 必须有oracle的环境变量,否则会提示##Message file RMAN<lang>.msb not found
##Verify that ORACLE_HOME is set properly
##${oracle_home}/bin/rman 必须时全路径的否则,会报不认识RMAN这个命#令
${oracle_home}/bin/rman target / nocatalog << EOF
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt expired archivelog all;
EOF
定时任务:
* */3 * * * /opt/oracle/product/11g/db/bin/cleanarclog.sh
cleanarclog.sh
#!/bin/bash
oracle_sid=mdspdb
oracle_home="/opt/oracle/product/11g/db"
ps -ef | grep oracle | grep -w "ora_lgwr_${oracle_sid}" >& /dev/null
if [ $? -ne 0 ]
then
exit 0
fi
source $HOME/.bash_profile ## 必须有oracle的环境变量,否则会提示##Message file RMAN<lang>.msb not found
##Verify that ORACLE_HOME is set properly
##${oracle_home}/bin/rman 必须时全路径的否则,会报不认识RMAN这个命#令
${oracle_home}/bin/rman target / nocatalog << EOF
crosscheck archivelog all;
delete noprompt obsolete;
delete noprompt expired archivelog all;
EOF
定时任务:
* */3 * * * /opt/oracle/product/11g/db/bin/cleanarclog.sh
本文介绍了一个用于定时清理Oracle数据库中过期归档日志的Shell脚本。该脚本通过设置环境变量并使用RMAN命令进行归档日志的检查与删除操作。具体步骤包括确认Oracle实例运行状态、配置环境变量、执行RMAN命令等。
3478

被折叠的 条评论
为什么被折叠?



