Answer the question
In order to leave comments, you need to log in
Why doesn't cron execute a php script from the admin with a reboot command, but does it manually?
The script looks like this:
include_once "smsc_api.php"; //прикладываем библиотеку для отправки смс
$doc = new DomDocument;
$doc->validateOnParse = true;
$res = $doc->Load('http://example.ru/feed/'); //Получаем ресурс с сайта
if (!$res) { //если ресурс не получен, значит сервак упал
exec("service mysqld restart"); //Перезагружаем сервер БД
list($sms_id, $sms_cnt, $cost, $balance) = send_sms("79176329140", "Server is down. Trying to restart...", 1); // Отправляем смс о том, что СУБД упала и была перезагружена
} else {
echo "No problem";
}
?>
Answer the question
In order to leave comments, you need to log in
do you have www-data in sudouser ?
exec('sudo -u www-data -S /etc/init.d/mysql restart');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question