报警日志每天备份的脚本

来源:互联网 发布:linux 安装ssh2扩展 编辑:程序博客网 时间:2024/05/16 10:58
export ORACLE_BASE=/app/oracleexport ORACLE_SID=orcldate=`date +%Y%m%d`alert_log_path="$ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace"alert_log_file="alert_$ORACLE_SID.log"alert_arc_file="alert_$ORACLE_SID.log""."${date}cd ${alert_log_path};if [ ! -e "${alert_log_file}" ]; then        echo "the alert log didn't exits, please check file path is correct!";        exit;fiif [ -e ${alert_arc_file} ];then        echo "the alert log file have been archived!"else        cat ${alert_log_file} >> ${alert_arc_file}        cat /dev/null > ${alert_log_file}fialert_log_path_lsnr="$ORACLE_BASE/diag/tnslsnr/linuxdb2/listener/trace"alert_log_file_lsnr="listener.log"alert_arc_file_lsnr="listener.log""."${date}cd ${alert_log_path_lsnr};if [ ! -e "${alert_log_file_lsnr}" ]; then        echo "the listener alert log didn't exits, please check file path is correct!";        exit;fiif [ -e ${alert_arc_file_lsnr} ];then        echo "the listener alert log file have been archived!"else        cat ${alert_log_file_lsnr} >> ${alert_arc_file_lsnr}        cat /dev/null > ${alert_log_file_lsnr}fi

crontab -e59 23 * * * /home/oracle/script/archive_alert_orcl_log.sh >/home/oracle/script/archive_alert_orcl_log.log
改脚本实现的功能是

1、每天晚上23点59分自动的把oracle的报警日志加上时间序号备份出来,并把原来的报警日志的内容清空

2、每天晚上23点59分自动的把监听的报警日志加上时间序号备份出来,并把原来的报警日志的内容清空

0 0
原创粉丝点击