首页 > Web开发 > 详细

监控http服务脚本

时间:2017-09-21 21:40:12      阅读:295      评论:0      收藏:0      [点我收藏+]
[root@ob1 scripts]# vim test_httpd.sh 
  1 #!/bin/bash
  2 #ss -tlnup|grep :80 >/dev/null 2>&1
  3 dk=$(ss -tlnup|awk -F"[ :]+" ‘/80/{print $5}‘)
  4 if [ "80" = "${dk}" ];then           #use string to compare,num is not have null
  5         echo "httpd is running"
  6 else
  7         echo "restarting"
  8         /etc/init.d/httpd restart >/dev/null 2>&1
  9 fi


如果服务没起就重启,if [ "80" = "${dk}" ];then          在字符串比较80 -eq dk 没起是空的时候报错,写成字符串就不报错应为字符串有空,数字没值会报错

监控http服务脚本

原文:http://www.cnblogs.com/gaoyuechen/p/7571426.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!