【Shell脚本】根据起止日期获取Alert日志内容

编程入门 行业动态 更新时间:2024-10-18 10:21:40

【Shell脚本】根据<a href=https://www.elefans.com/category/jswz/34/1731686.html style=起止日期获取Alert日志内容"/>

【Shell脚本】根据起止日期获取Alert日志内容

【Shell脚本】根据起止日期获取Alert日志内容

根据输入的起止日期字符串,检索Oracle告警日志,打印中间的日志行内容。

#!/bin/bash
# $1 START_TIME_STR, e.g. "Oct 17 07:" 
# $2 END_TIME_STR, e.g. "Oct 17 08:"
source /home/oracle/.bash_profile
FILEPATH="$ORACLE_BASE/diag/rdbms/`hostname`/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log"retrieveLog()
{#echo $1,$2,$3lineStart=`grep -n "$1" "$3" | awk -F":" '{print $1}' | head -n1`lineEnd=`grep -n "$2" "$3" | awk -F":" '{print $1}' | tail -n1`echo "lineStart is ${lineStart}, lineEnd is ${lineEnd}."if [ -z "${lineStart}" ] || [ -z "${lineEnd}" ]then echo "lineStart and lineEnd cannot be empty!"elseecho "Retrieving the required log ..." echo "########################################################"sed -n "${lineStart},${lineEnd}p" $3echo "########################################################"echo "Finished retrieving the required log ..."fi 
}if [ -f "$FILEPATH" ]
thenretrieveLog "$1" "$2" "$FILEPATH"
elseecho "$FILEPATH does not EXIST! Please input the absolute log path."read -p "请输入日志文件路径: " LOGPATHretrieveLog "$1" "$2" "$LOGPATH"
fi

更多推荐

【Shell脚本】根据起止日期获取Alert日志内容

本文发布于:2023-12-06 22:24:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1669140.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:起止   脚本   日期   内容   日志

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!