您的位置:首页 > 数据库 > Oracle

Oracle ALert日志按时间保存脚本

2013-01-22 13:11 267 查看
以下脚本可以通过定时任务,每天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%".logrem 清空日志文件rem 下面一句是用来清空alert_orcl.log的cd. >C:\app\backup\alert_orcl.logpauseLinux平台下脚本将alert log 按天存放,每天一个alert log 文件#!/bin/bashDATE=`date +%Y%m%d`cd /u01/app/oracle/diag/rdbms/orcl/orcl/traceif [ -f alert_SID.log ]; thenif [ -f alert_SID _$DATE.log ]; thenecho "the file is exits!"elsecat alert_SID.log >> alert_SID _$DATE.logcat /dev/null > alert_SID.logfifi2 将alert 文件放到一个历史文件里(会清空本身的alart文件)#!/bin/kshcd /u01/app/oracle/diag/rdbms/orcl/orcl/traceif [ -f alert_orcl.log ]; thencat alert_orcl.log >> alert_orcl.hist cat /dev/null > alert_orcl.logfi>> 会放在文件的最后。 > 会覆盖原来的内容。 crontab -ecrontab -l计划任务:18 15 * * * /u01/app/shell/masicong2 >/u01/app/alertlogbyday.log 2>&1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Oracle 时间