您好,登錄后才能下訂單哦!
#!/bin/bash
#By:sadoc.blog.51cto.com
. /etc/rc.d/init.d/functions
MYUSER=root
MYPASS="123456"
MYSOCK=/var/lib/mysql/mysql.sock
MY_START="systemctl start mysqld.service"
LOG_PATH=/tmp/mysql
MY_PATH=/usr/bin/mysql
DAYS=`date +%F`
SECOND=`date +%Y/%m/%d-%H:%M:%S`
STARTING="${LOG_PATH}/start-$DAYS.log"
[ -d $LOG_PATH ] || mkdir -p $LOG_PATH
MY_CMD="$MY_PATH -u$MYUSER -p$MYPASS -S $MYSOCK"
$MY_CMD -e "select version ();" >/dev/null 2>&1
if [ $? -eq 0 ];then
action "$SECOND----Mysql" /bin/true >>$LOG_PATH/my_status.log
exit 0
else
$MY_START >>$STARTING
sleep 5;
$MY_CMD -e "select version ();" >/dev/null 2>&1
if [ $? -ne 0 ];then
for down in `seq 5`
do
systemctl stop mysqld.service >/dev/null 2>&1
[ $? -ne 0 ] && break;
sleep 2;
done
$MY_START >>$STARTING
fi
$MY_CMD -e "select version ();" >/dev/null 2>&1 && Status="restarted" || Status="unkown"
echo "$SECOND------Mysql status is $Status" >>$LOG_PATH/my_status.log
fi
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。