#!/bin/bash
while true;do
echo "************************************************************"
date
# ================================================================
TCPListeningnum=`netstat -an | grep ":5000" | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l`
if [ $TCPListeningnum -eq 0 ]
then
{
echo "listener port is down">>/root/1.log
#如果5000端口down了,重启tomcat服务
cd /Smaritbi/apache-tomcat-7.0.34/bin/
./shutdown.sh
./start.sh
}
else
{
echo " 5000端口正常" >>/root/l.log
date
}
fi
sleep 5;
done
~
执行该脚本
nohup sh 1.sh > /dev/null 2>&1&
while true;do
echo "************************************************************"
date
# ================================================================
TCPListeningnum=`netstat -an | grep ":5000" | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l`
if [ $TCPListeningnum -eq 0 ]
then
{
echo "listener port is down">>/root/1.log
#如果5000端口down了,重启tomcat服务
cd /Smaritbi/apache-tomcat-7.0.34/bin/
./shutdown.sh
./start.sh
}
else
{
echo " 5000端口正常" >>/root/l.log
date
}
fi
sleep 5;
done
~
执行该脚本
nohup sh 1.sh > /dev/null 2>&1&
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30345407/viewspace-2124973/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30345407/viewspace-2124973/