#!/bin/sh
ps -fe|grep mysqld |grep -v grep
if [ $? -ne 0 ]
then
echo "start process....."
service mysql start
else
echo "runing....."
fi
DATE=`date +%Y%m%d%H%M%S`
echo $DATE >> /backup/mysql/test.txt
0表示存在的
$? -ne 0 不存在,$? -eq 0 存在
vi /etc/crontab
*/5 * * * * root /backup/mysql/mysql.sh
crontab /etc/crontab
加入自动执行,每5分钟监测一次
如果挂了,自动重启
You must be logged in to post a comment.
感谢大佬的帮助