zoukankan      html  css  js  c++  java
  • shell监控网站是否自动运行并自动重启【原创】

    shell监控网站是否自动运行并自动重启

    #!/bin/bash
    wget --spider -q -o /dev/null --tries=1 -T 5 www.baidu.com
    if [ $? -eq 0 ];then
      echo "`date` 网站访问正常!" >> /root/web_monitor.log
    else
      echo "`date` 网站访问异常!重启服务" >> /root/web_monitor.log
      #重启服务脚本   
    sh /root/restart.sh   if [ $? -eq 0 ];then     echo "`date` 重启服务成功" >> /root/web_monitor.log   else     echo "`date` 重启服务失败" >> /root/web_monitor.log     exit   fi fi

    也可以使用curl监控网页返回代码

    curl -o /dev/null --retry 3 --retry-max-time 8 -s -w %{http_code} www.baidu.com

  • 相关阅读:
    OSI模型白话
    并发
    初始化与清理
    多线程
    recyclerview Adapter
    recyclerview刷新
    surfaceview
    viewgroup绘制流程
    view配置
    项目遇到的问题
  • 原文地址:https://www.cnblogs.com/paul8339/p/7843535.html
Copyright © 2011-2022 走看看