如何检查网页是否包含文本“连接到数据库时出错”以及页面中是否存在文本重新启动数据库?
这是我到目前为止所拥有的,但它不起作用:
check host website.com with address website.com
group database
start program = "/usr/bin/service mysql start"
stop program = "/usr/bin/service mysql stop"
if url http://website.com content == "Error connecting to database" then restart
Run Code Online (Sandbox Code Playgroud) 我有一个问题,即 MySQL(在 Ubuntu 12.04 上运行所有最新更新)在几天后死亡,因此将此脚本放入一个 cron 作业中,该作业每 60 秒以 root 身份运行。
一切正常,除了 mysql 服务不会重新启动,我试过使用“service mysql restart”和“/usr/bin/mysqld”,但它们也不起作用。
我正在使用完整路径来重新启动命令,所以我认为这不是问题。现在唯一有效的是用“重启”替换重启命令,这非常难看,我想避免它。
#!/bin/bash
#Check if MySQL is up, if not then start it
# mysql root/admin username
MUSER="root"
# mysql admin/root password
MPASS="REMOVED"
# mysql server hostname
MHOST="localhost"
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
# Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS.
MSTART="/etc/init.d/mysql restart"
# Email ID to send notification
EMAILID="some@email.net"
# …
Run Code Online (Sandbox Code Playgroud)