echo $(date ‘+%Y-%m-%d %H:%M:%S’)
whoami
JAVA_HOME=/opt/java/jdk1.8.0_40
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
port=8086
sn=“tomcat-image-$port“
th=“/home/dev/tomcat/$sn“
url=“http://you-app-server/”
tomcat=`ps -ef | grep java | grep $sn | grep $port | wc -l`
if [ $tomcat -eq 0 ]
then
echo $sn stoped.
echo starting $sn ……
$th/bin/startup.sh
fi
if [ $tomcat -ge 1 ]
then
tpid=`ps -ef | grep java | grep $sn | grep $port | awk ‘{print $2}’`
echo $sn is running, pid = $tpid
httpStatus=`curl -I $url 2>/dev/null | grep HTTP | awk ‘{print $2}’`
echo $httpStatus
if [[ -z “$httpStatus“ || $httpStatus -ge 500 ]]
then
echo killing $sn ……
kill -9 $tpid
echo starting $sn ……
$th/bin/startup.sh
fi
fi
crontab -e
*/5 * * * * /tomcat-inspector/image.sh >> /logs/image.log 2>&1
|
Recent Comments