header

shell Script to monitor log file

Below script will monitor for the error log file updated date every 5 minutes and compare it with the current date and send email if it is updated today.After the issue has been fixed you may need to backup the old log

Scheduled to run 5 mins:


0,5,10,15,20,25,30,35,40,45,50,55 * * * * /opt/hrms/webserv/hr/applications/peoplesoft/PSIGW/monitor.sh



Monitor.sh Script:

#!/bin/sh

cd /opt/hrms/webserv/hr/applications/peoplesoft/PSIGW

Current_Date=`date +"%b %e"`

Filerrordate=`ls -ltr /opt/hrms/webserv/hr/applications/peoplesoft/PSIGW/errorLog.html
awk '{print $6,$7}'`

if [ "$Current_Date" = "$Filerrordate" ] ; then

echo $Current_Date":Error logged in IB gateway log" >> /opt/hrms/webserv/hr/applications/peoplesoft/PSIGW/dailystatus.log

cat errorLog.html
mailx -s "URGENT::Error occured in IB Gateway please Check immediatly" xxxx@name.com

exit 0

else

echo $Current_Date":No new error in error log" >> /opt/hrms/webserv/hr/applications/peoplesoft/PSIGW/dailystatus.log

exit 0

fi

No comments: