Oracle: read the entries from alert log
Saturday, November 3rd, 2007Sometimes it’s necessary to read the information from the alert log together with the timestamp of the error.
The very simple Unix-shell script helps to do this:
echo
echo ‘Enter # of lines:’
read NUM
tail -$NUM alert_${ORACLE_SID}.log | awk ‘
BEGIN {prev=”" ; ret=1 }
/^(…-|Error)/ { if ( prev !~ /^(…-|Error)/ ) { print “” ; print prev;} [...]
Redirect script output to the log
Wednesday, March 8th, 2006If the whole output of the complex script should be redirected to the log, the following trick could be used.
if [ "$1" != "-log" ] ; then
$0 -log “$@” 2>&1 | tee the_log_file.$$.log
echo “The log file for the current session: the_log_file.$$.log”
exit 0
fi
shift # remove “-log” [...]
Search for Oracle errors in the alert log
Friday, February 3rd, 2006Search for Oracle errors in the last $NUM lines.
NUM=1000
SIGNAL_LIST=’^(…-|Error|Starting.*instance)|terminating instance’
tail -$NUM alert_${ORACLE_SID}.log | awk ‘
BEGIN {prev=”" ; ret=1 }
/’”$SIGNAL_LIST”‘/ { if ( prev !~ /’”$SIGNAL_LIST”‘/ ) { print “” ; print prev;} print $0;ret=0}
{prev=$0}
END { exit ret } ‘
On Unix Oracle alert log is normally located in bdump/alert_${ORACLE_SID}.log