Oracle ALert日志按时间保存脚本

以下脚本可以通过定时任务,每天0点执行,让警告日志按照时间分类,自动保存到相应目录中。方便对每天所产生的Alart日志进行查看。

windows下脚本

rem 复制日志文件并改名,请根据SID情况修改脚本

set year=%DATE:~0,4%
set month=%DATE:~5,2%
set day=%DATE:~8,2%
copy C:\app\Administrator\diag\rdbms\orcl\orcl\trace\alert_orcl.log C:\app\backup\alert_orcl"%
year%%month%%day%".log
rem 清空日志文件
rem 下面一句是用来清空alert_orcl.log的
cd. >C:\app\backup\alert_orcl.log
pause
Linux平台下脚本
将alert log 按天存放,每天一个alert log 文件
#!/bin/bash
DATE=`date +%Y%m%d`
cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace
if  [ -f alert_SID.log ];  then
if  [ -f alert_SID _$DATE.log ]; then
echo "the file is exits!"
else
cat alert_SID.log >> alert_SID _$DATE.log
cat /dev/null > alert_SID.log
fi
fi
2 将alert 文件放到一个历史文件里(会清空本身的alart文件)
#!/bin/ksh
cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace
if  [ -f alert_orcl.log ];  then
cat alert_orcl.log >> alert_orcl.hist  
cat /dev/null > alert_orcl.log
fi
>> 会放在文件的最后。
> 会覆盖原来的内容。
crontab -e
crontab -l
计划任务:
18 15  * * *  /u01/app/shell/masicong2  >/u01/app/alertlogbyday.log 2>&1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值