平淡的流年

BLOG&PAGE

Shell脚本监控80端口

发布时间:2016-8-15 编辑:流年 阅读(103)

#! /bin/bash
A="Ture"
B="Flase"
website=`curl -I -s http://blog.pddln.com | head -1 | cut -d " " -f2`
Kill=`lsof -i:80`
if [ $website = "200" ]
  then
  echo "$A" >>/home/nbtv_jk/website.`date +%F`.log
else
 kill -9 $Kill
 /etc/rc.d/init.d/httpd restart
 echo "$B" >>/home/nbtv_jk/website-error.`date +%F`.log
 echo "[`date +%y%m%d/%H:%M:%S`],Website has a problem has been fixed, please confirm" |mail -s sns.nbtv.cn 15258279063@139.com

fi

安装sendmail 安装mail 开启25端口

编辑/etc/mail.rc


set from=longl880306@sina.com
set smtp=smtp.sina.com
set smtp-auth-user=longl880306@sina.com
set smtp-auth-password=*****
set smtp-auth=login


----平淡的流年

暂无评论

添加新评论