首页 > 代码库 > 重启tomcat shell
重启tomcat shell
#!/bin/bash #1、判断服务是否可用 2、不可用重启tomcat #*/30 * * * * /home/wsm/restart.sh >> /home/wsm/restart.log #停止tomcat function killTomcat(){ pid=`ps -ef | grep "/home/wsm/bin/tomcat" | grep -v grep | awk '{print $2}'` if [ -n "$pid" ];then ps -ef | grep "/home/wsm/bin/tomcat" | grep -v grep | awk '{print $2}' | xargs kill -9 fi sleep 10 echo `date "+%Y-%m-%d %H:%M:%S"` "| killd tomcat " } #启动tomcat function startTomcat(){ pid=`ps -ef | grep "/home/wsm/bin/tomcat" | grep -v grep | awk '{print $2}'` if [ -n "$pid" ];then ps -ef | grep "/home/wsm/bin/tomcat" | grep -v grep | awk '{print $2}' | xargs kill -9 sleep 10 else /home/wsm/bin/startup.sh echo `date "+%Y-%m-%d %H:%M:%S"` "| start tomcat end" fi } ctime=`date "+%Y-%m-%d %H:%M:%S"` export JAVA_HOME="/usr/java/jdk1.7.0_21" #export PATH="$JAVA_HOME/bin:$PATH" export PATH="/usr/java/jdk1.7.0_21/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" export LANG="en_US.UTF-8" #获取本机IP localip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'` #调用本机应用服务,获取http返回码 STATUS_CODE=`/usr/bin/curl -o /dev/null -s -m 13 --connect-timeout 30 -w %{http_code} $localip:8080/WSMMeasure/str/report/performancereport` echo $ctime " | STATUS_CODE= " $STATUS_CODE #如果返回码不是200 重启tomcat if [ $STATUS_CODE -ne 200 ];then echo "STATUS_CODE=" $STATUS_CODE #killTomcat echo `export` >> /home/wsm/restart.log echo `date "+%Y-%m-%d %H:%M:%S"`"|100001|killtomcat" #startTomcat echo `date "+%Y-%m-%d %H:%M:%S"`"|100002|starttomcat" fi
重启tomcat shell
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。