美文网首页
利用crontab定时运行监控脚本

利用crontab定时运行监控脚本

作者: 黑客不黑_ | 来源:发表于2019-04-11 18:26 被阅读0次

    写了个监控jar包进程的脚本

    #!/bin/sh
    runlogistic(){
      echo " logistic-service.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countlogistic=`ps -ef|grep logistic-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countlogistic" ]; then
        echo "logistic-service.jar is running!"
      else
        echo "logistic-service.jar is stoped! try to run it!"
        sh /home/www/new-retail/common-logistic-service/service/yun.sh
      fi
    }
    runlogistic
    
    runbhuserweb(){
      echo " bh-user-web.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhuserweb=`ps -ef|grep bh-user-web.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhuserweb" ]; then
        echo "bh-user-web.jar is running!"
      else
        echo "bh-user-web.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-user/web/yun.sh
      fi
    }
    runbhuserweb
    
    runbhuserservice(){
      echo " bh-user-service.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhuserservice=`ps -ef|grep bh-user-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhuserservice" ]; then
        echo "bh-user-service.jar is running!"
      else
        echo "bh-user-service.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-user/service/yun.sh
      fi
    }
    runbhuserservice
    
    runbhtimedtask(){
      echo " bh-timed-task.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhtimedtask=`ps -ef|grep bh-timed-task.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhtimedtask" ]; then
        echo "bh-timed-task.jar is running!"
      else
        echo "bh-timed-task.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-timer/task/yun.sh
      fi
    }
    runbhtimedtask
    
    runbhstrategyservice(){
      echo " bh-strategy-service.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhstrategyservice=`ps -ef|grep bh-strategy-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhstrategyservice" ]; then
        echo "bh-strategy-service.jar is running!"
      else
        echo "bh-strategy-service.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-strategy/service/yun.sh
      fi
    }
    runbhstrategyservice
    
    runbhstrategyweb(){
      echo " bh-strategy-web.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhstrategyweb=`ps -ef|grep bh-strategy-web.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhstrategyweb" ]; then
        echo "bh-strategy-web.jar is running!"
      else
        echo "bh-strategy-web.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-strategy/web/yun.sh
      fi
    }
    runbhstrategyweb
    
    runbhgatewaytest(){
      echo " bh_gateway_test.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhgatewaytest=`ps -ef|grep bh_gateway_test.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhgatewaytest" ]; then
        echo "bh_gateway_test.jar is running!"
      else
        echo "bh_gateway_test.jar is stoped! try to run it!"
        sh /home/www/gateway-service/yun.sh
      fi
    }
    runbhgatewaytest
    
    runbhnewretailshopweb(){
      echo " bh-newretail-shop-web.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhnewretailshopweb=`ps -ef|grep bh-newretail-shop-web.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhnewretailshopweb" ]; then
        echo "bh-newretail-shop-web.jar is running!"
      else
        echo "bh-newretail-shop-web.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-shop/web/yun.sh
      fi
    }
    runbhnewretailshopweb
    
    runbhnewretailshopservice(){
      echo " bh-newretail-shop-service.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhnewretailshopservice=`ps -ef|grep bh-newretail-shop-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhnewretailshopservice" ]; then
        echo "bh-newretail-shop-service.jar is running!"
      else
        echo "bh-newretail-shop-service.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-shop/service/yun.sh
      fi
    }
    runbhnewretailshopservice
    
    runbhpayweb(){
      echo " bh-pay-web.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhpayweb=`ps -ef|grep bh-pay-web.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhpayweb" ]; then
        echo "bh-pay-web.jar is running!"
      else
        echo "bh-pay-web.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-pay/web/yun.sh
      fi
    }
    runbhpayweb
    
    runbhpayservice(){
      echo " bh-pay-service.jar is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhpayweb=`ps -ef|grep bh-pay-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhpayweb" ]; then
        echo "bh-pay-service.jar is running!"
      else
        echo "bh-pay-service.jar is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-pay/service/yun.sh
      fi
    }
    runbhpayservice
    
    runbhbackmanager(){
      echo " bh-back-manager is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhbackmanager=`ps -ef|grep bh-back-manager.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhbackmanager" ]; then
        echo "bh-back-manager is running!"
      else
        echo "bh-back-manager is stoped! try to run it!"
        sh /home/www/new-retail/new-retail-manager/web/yun.sh
      fi
    }
    runbhbackmanager
    
    runbhmsgpushservice(){
      echo " bhmsgpushservice is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhmsgpushservice=`ps -ef|grep bh-msg-push-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhmsgpushservice" ]; then
        echo "bhmsgpushservice is running!"
      else
        echo "bhmsgpushservice is stoped! try to run it!"
        sh /home/www/new-retail/msg-push/service/yun.sh
      fi
    }
    runbhmsgpushservice
    
    runbhwalletservice(){
      echo " bhwalletservice is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhwalletservice=`ps -ef|grep bh-wallet-service.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhwalletservice" ]; then
        echo "bhwalletservice is running!"
      else
        echo "bhwalletservice is stoped! try to run it!"
        sh /home/www/wallet/product/service/yun.sh
      fi
    }
    runbhwalletservice
    
    runbhwalletweb(){
      echo " bhwalletweb is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhwalletweb=`ps -ef|grep bh-wallet-web.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhwalletweb" ]; then
        echo "bhwalletweb is running!"
      else
        echo "bhwalletweb is stoped! try to run it!"
        sh /home/www/wallet/product/web/yun.sh
      fi
    }
    runbhwalletweb
    
    runbhcommonserviceserver(){
      echo " bhcommonserviceserver is already running!"
      #ps x | grep saas-tomcat | grep -v grep | grep -v sh
      countbhcommonserviceserver=`ps -ef|grep bh-common-service-server.jar|grep -v grep|awk '{print $2}'`
      if [ -n "$countbhcommonserviceserver" ]; then
        echo "bhcommonserviceserver is running!"
      else
        echo "bhcommonserviceserver is stoped! try to run it!"
        sh /home/www/common/thrift-rpc/yun.sh
      fi
    }
    runbhcommonserviceserver
    

    相关文章

      网友评论

          本文标题:利用crontab定时运行监控脚本

          本文链接:https://www.haomeiwen.com/subject/fpdbeqtx.html