import requests
import os
import time
url = 'http://www.ydyigo.com/findPwd.php'

def get_server_status(url):
    try:
        res = requests.head(url,timeout=30)
        return res.status_code
    except:
        print 'timeout'

if __name__ == '__main__':
    if get_server_status(url) != 200:
        os.system("service httpd restart")
        str = "restart  :%s \r\n" % time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))
    else:
        str = "status ok:%s \r\n" % time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))
    with open("/www/web/pythontask/count.txt","a+") as f:
        f.write(str)

相关文章:

  • 2021-04-19
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
猜你喜欢
  • 2022-12-23
  • 2021-12-01
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案