清理oracle10g日志----shell脚本定时任务执行rman

定时执行脚本:
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,脚本,bash)