I am trying to write script that monitors log file and on specific error it performs certain function. I got the main code working however stuck with one problem. Application create new log file when system date changes (log file name pattern is LOG.NODE1.DDMMYYYY), how do I get my code to automatically switch to new file that is created. Following is my script so far,
#!/bin/sh
logfile=$(ls -t $DIR"/env/log/LOG"* | head -n 1)
echo $logfile
tail -f $logfile | while read LOGLINE
do
if [[ "${LOGLINE}" == *";A database exception has occurred: FATAL DBERR: SQL_ERROR: ORA-00001: unique constraint (IX_TEST1) violated"* ]];
then
#Do something
fi
done