ITPub博客

首页 > 数据库 > Oracle > 报警日志每天备份的脚本

报警日志每天备份的脚本

原创 Oracle 作者:531968912 时间:2016-09-14 11:27:30 0 删除 编辑
[sql] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. export ORACLE_BASE=/app/oracle  
  2. export ORACLE_SID=orcl  
  3. date=`date +%Y%m%d`  
  4. alert_log_path="$ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace"  
  5. alert_log_file="alert_$ORACLE_SID.log"  
  6. alert_arc_file="alert_$ORACLE_SID.log""."${date}  
  7. cd ${alert_log_path};  
  8. if [ ! -e "${alert_log_file}" ]; then  
  9.         echo "the alert log didn't exits, please check file path is correct!";  
  10.         exit;  
  11. fi  
  12. if [ -e ${alert_arc_file} ];then  
  13.         echo "the alert log file have been archived!"  
  14. else  
  15.         cat ${alert_log_file} >> ${alert_arc_file}  
  16.         cat /dev/null > ${alert_log_file}  
  17. fi  
  18.   
  19.   
  20. alert_log_path_lsnr="$ORACLE_BASE/diag/tnslsnr/linuxdb2/listener/trace"  
  21. alert_log_file_lsnr="listener.log"  
  22. alert_arc_file_lsnr="listener.log""."${date}  
  23.   
  24. cd ${alert_log_path_lsnr};  
  25. if [ ! -e "${alert_log_file_lsnr}" ]; then  
  26.         echo "the listener alert log didn't exits, please check file path is correct!";  
  27.         exit;  
  28. fi  
  29. if [ -e ${alert_arc_file_lsnr} ];then  
  30.         echo "the listener alert log file have been archived!"  
  31. else  
  32.         cat ${alert_log_file_lsnr} >> ${alert_arc_file_lsnr}  
  33.         cat /dev/null > ${alert_log_file_lsnr}  
  34. fi  


[sql] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. crontab -e  
  2. 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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-09-24

  • 博文量
    576
  • 访问量
    1111403