shell脚本同时启动关闭多个tomcat
服务器上有两个tomcat,/usr/local/tomcat/tomcat1和/usr/local/tomcat/tomcat2现需要将tomcat加入服务,通过ser...
服务器上有两个tomcat,/usr/local/tomcat/tomcat1和/usr/local/tomcat/tomcat2
现需要将tomcat加入服务,通过service tomcat start/stop/restart管理tomcat服务,并要求启动时打印启动日志,多个tomcat按顺序一次性启动。 展开
现需要将tomcat加入服务,通过service tomcat start/stop/restart管理tomcat服务,并要求启动时打印启动日志,多个tomcat按顺序一次性启动。 展开
2个回答
2017-05-22
展开全部
同时启动关闭多个tomcat可以参考如下示例
#!/bin/ksh
log=/var/log/tomcat_web/tomcatrun-logthome=/usr/local/tomcat
ip="192.168.1.35"
port="8085"
cluster="192.168.1.35:8080|tomcat1 192.168.1.35:8085|tomcat2"
for server in $cluster
do
echo "$server"|while IFS="|" read f1 f2
do
host="$f1"
servicename="$f2"
result=`/usr/bin/wget -S --spider --tries=3 --timeout=3 http://$host/blank/word.jsp 2>&1 | grep HTTP/1.1|awk '{print $2}'`
if [ "$result" = "200" ]
then
echo "Tomcat $host $servicename Running OK"
else
sleep 5
result=`/usr/bin/wget -S --spider --tries=5 --timeout=3 http://$host/blank/word.jsp 2>&1 | grep HTTP/1.1|awk '{print $2}'`
if [ "$result" = "200" ]
then
echo "Tomcat $host $servicename Running OK"
else
echo "Tomcat $host $servicename is not runnng : `date +%Y/%m/%d-%H:%M:%S`"
service $servicename start
echo "Tomcat $host $servicename restart finish."
fi
fi
done
done
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询