Hi,
I have written a shell script to grep a certain parameter and send a mail if they found any. Now i want this script to call another script which will restart my application.
Here is my script
#!/bin/sh
DATE=`date +%Y%m%d%H%M%S`
HOME=/home/dumbren/vfnz_data/AMS_report
LOG_DIR=/apps/prod/vfonline/weblogic100/domains/vfop6dom/servers/ams-stream1-svr1/logs
JKIT=/apps/prod/vfonline/weblogic100/domains/vfop6dom/servers/ams-stream1-svr1
CONSOLE_FILE=console.log.20110405175955
ALERTS_FILE=alerts_ejb1.log.1
CONSOLE_OUTPUT=/home/dumbren/vfnz_data/console
ALERTS_OUTPUT=/home/dumbren/vfnz_data/alerts
APPLICATION_PID=`ps -ef | grep "ams-1" | grep -i java |awk '{ print $2 }'`
#-------------------------------------------------------------------------------------------------------
#
# To find exception "OutOfMemory" in logs and restart application if we found any
#
#-------------------------------------------------------------------------------------------------------
cd $LOG_DIR
tail -f $CONSOLE_FILE > $CONSOLE_OUTPUT &
grep "java.lang.OutOfMemoryError" $CONSOLE_FILE > $CONSOLE_OUTPUT
sleep 10
`ps -ef | sed -n '/tail/{/grep/!p;}' | grep "console.log" |awk '{print$2}' | xargs -i kill {}`
sleep 10
a=`ls -lrth $CONSOLE_OUTPUT |awk '{print$5}'`
if [ $a -eq 0 ];
then
echo "The file is empty"
else
echo "The Vaule of A differs, please check"
#/usr/bin/printf "***** AMS ALERT - $DATE *****\n\nHost: `hostname` \n\nDATE: `date` \n\n" | /bin/mail -s " AMS Error $DATE " user@dom.com
m < /home/dumbren/console
fi
exit 0
here is it find any exception then it should directly call the other script "./ams_rc stop" which will stop application and then will start the same with same script "./ams_rc start"
Regards,
SiddheshK