-
export ORACLE_BASE=/app/oracle
-
export ORACLE_SID=orcl
-
date=`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;
-
fi
-
if [ -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}
-
fi
-
-
-
alert_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;
-
fi
-
if [ -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 -e
-
59 23 * * * /home/oracle/script/archive_alert_orcl_log.sh >/home/oracle/script/archive_alert_orcl_log.log
改脚本实现的功能是
1、每天晚上23点59分自动的把oracle的报警日志加上时间序号备份出来,并把原来的报警日志的内容清空
2、每天晚上23点59分自动的把监听的报警日志加上时间序号备份出来,并把原来的报警日志的内容清空
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25462274/viewspace-2124968/
,如需转载,请注明出处,否则将追究法律责任。