需要mutt和sendmail

yum -y install mutt sendmail sendmail-devel- #!/bin/bash

  • url="http://www.hostloc.com"
  • status=$(curl -s --head "$url"|awk '/HTTP/ {print $2}')
  • email="admin@google.com"
  • date=date -d today +"%Y-%m-%d %H:%M"
  • if [ "$status" != "200" ]; then
  • mutt -s "HTTP exception ($status) detected" $email 复制代码