#!/bin/sh
#This is check msyqld shell
#by:key1088@163.com
#守护mysqld脚本,防止意外崩溃。
#如果连接启动10次,依旧启动不来了。停止(可以写成运行某个程序),解决内存。
ERRLOG=/videodata/mysqldata/data/CHINASOFT.err
load_mysqld ()
{
/etc/init.d/mysqld start
}
while true
do
i=1
PRO=ps aux|grep mysqld|grep -v grep
if [ -z "$PRO" ]
then
while true
do
if [ -z "$PRO" ]
then
load_mysqld
echo "date +'%y%m%d %H:%M:%S'
$0 LOAD MSYQLD-[$i]" >> $ERRLOG
sleep 20
PRO=ps aux|grep mysqld|grep -v grep
if [ -z "$PRO" ]
then
i=$((i+1))
fi
else
break
fi
if [ $i -eq 10 ]
then
echo "date +'%y%m%d %H:%M:%S'
HR_MYSQL_SAFE.SH LOAD MSQQLD –STOP" >> $ERRLOG
exit 1
fi
done
fi
sleep 20
done