Categories: Uncategorized

[Shell][mysql]Monitor mysqld process and reboot it if it’s needed

Target

mysqld die sometimes at my web app,
So I tried to make a shell script to reboot the process if the process died.

source

#!/bin/sh

PROCESS=`ps -ef | grep /usr/sbin/mysqld | grep -v grep | wc -l`
if test $PROCESS -eq 0
then
        LOG=`sudo /etc/init.d/mysql start`
fi

Make this run at a cycle with crontab.
zuqqhi2