Запускаем терминал
Создаем shell script файл
Записываем скрипт который проверяет и перезапускает mysql а также отправляет уведомление. В поле email@domain.com введите корректный email.
Создаем shell script файл
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~ | |
nano mysqlfix.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH=/usr/sbin:/usr/bin:/sbin:/bin | |
if [[ ! "$(/usr/sbin/service mysql status)" =~ "start/running" ]] | |
then | |
echo "MySQL restarted" | mail -s "Email Subject" email@domain.com | |
sudo service mysql start | |
fi |
Разрешаем запуск скрипта
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chmod +x launch.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crontab -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*/1 * * * * /root/mysqlfix.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/sbin/service mysql stop |
Комментариев нет:
Отправить комментарий