Check_Tomcat.sh
时间:2009-08-03 来源:h_xin8211
#!/bin/bash
# Check_Tomcat.sh 1.0 2009.08.02 Mr.hu
# if tomcat down. startup now. a note of the log. and SMS Alarm.
tomPatch=/usr/local/tomcat6020
tomreblogPatch=$tomPatch/logs/tomreblog.txt
ndate="date +%Y-%m-%d---%T"
if netstat -tnl |grep "8080" >> /dev/null
then
:
else
$ndate >> $tomreblogPatch
echo "____________________________________" >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== tomcat is down , startup now... ===" >> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
$tomPatch/bin/startup.sh >> $tomreblogPatch
echo >> $tomreblogPatch
echo "=== catalina.out of The last 30 lines" ===>> $tomreblogPatch
echo ">>>" >> $tomreblogPatch
sleep 10
tail -n 30 $tomPatch/logs/catalina.out>> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
echo >> $tomreblogPatch
fi