直近の起動を探すのが面倒なのでスクリプト化した。
環境変数は以下を設定する。
- ORACLE_BASE
- ORACLE_SID
- ORACLE_UNQNAME
show_alert.sh
#!/bin/bash -x
MARKERWD="Starting ORACLE instance"
ALERTLOG=$ORACLE_BASE/diag/rdbms/$ORACLE_UNQNAME/$ORACLE_SID/trace/alert_$ORACLE_SID.log
LOGLENGTH=`wc -l $ALERTLOG | cut -f1 -d\ `
LASTSTART=`grep "$MARKERWD" $ALERTLOG -n | cut -f1 -d : | tail -n 1`
TAILCOUNT=`expr $LOGLENGTH - $LASTSTART + 1`
#echo $TAILCOUNT
#echo $LOGLENGTH
#echo $TAILCOUNT
echo $ALERTLOG
echo "----------------------------------------------------"
tail -n $TAILCOUNT $ALERTLOG
わざわざシェル化しなくとも
多分他にももっといい方法あるとおもう。