首先restart_mysql.sh文件如下
# !/bin/sh
pidof mysqld >/dev/null
if [ $? -eq 0 ]
then
echo "running...">> ./mysql_log.txt
else
echo " mysql server was stopped">> ./mysql_log.txt
service mysql start
fi
crontab -e 进入编辑如下
*/2 * * * * /var/spool/cron/restart_mysql.sh
接着
service crond restart
```两分钟后去看 mysql_log.txt 是空的, 但是直接在该目录下 ./restart_mysql.sh之后去查看mysql_log.txt,能看到增加了一条信息。。。