Скрипт проверяет сайт на доступность, и вслучае получения 502 статуса перезапускает Apache, о чем делает временную метку в log файл 
apache502.log
#!/bin/bash
log_msg()
{
    if [ ! -e /home/apache502.log ]; then
        touch /home/apache502.log
        chmod 0640 /home/apache502.log
    fi
    echo "$(date +'[%Y-%m-%d %T]') $1" >> /home/apache502.log
}
status=$(awk 'BEGIN {"curl -sI https://site.ru" | getline; print "" $2}')
if [ $status = 502 ]; then
    service apache2 restart
    log_msg "Apache was restarted!"
# else
#
#    echo "Apache up and running"
#    log_msg "Apache up and running!"
fiЗапихиваем его в cron например с запуском раз в 5 минут
comments powered by HyperComments