Chinaunix首页 | 论坛 | 博客
  • 博客访问: 211628
  • 博文数量: 49
  • 博客积分: 1532
  • 博客等级: 上尉
  • 技术积分: 352
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-17 13:37
个人简介

..................................

文章分类

全部博文(49)

文章存档

2023年(1)

2020年(2)

2019年(2)

2018年(17)

2017年(15)

2016年(12)

分类: Mysql/postgreSQL

2017-07-19 15:46:22



#!/bin/bash
 
result=`/usr/bin/mysqladmin ping`
expected='mysqld is alive'
 
if [[ "$result" != "$expected" ]]
then
echo "It's dead - restart mysql"
 
# email subject
SUBJECT="[MYSQL ERROR] - Attempting to restart service"
 
# Email To ?
EMAIL="info@endyourif.com"
 
# Email text/message
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "$result was received"> $EMAILMESSAGE
echo "when we were expected $expected" >>$EMAILMESSAGE
# send an email using /bin/mail
mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
 
sudo /etc/init.d/mysql restart
fi


阅读(609) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~