Articles & Code Snippets


Bash Script Check is Apache is Down

Bash script to check if Apache server is up and running. If server is down, we will do a restart




#!/bin/bash
if curl -s --head 'https://your-domain.com/' | grep "200 OK" > /dev/null
  then 
    echo "Apache server is up!" > /dev/null
  else
    echo "Apache server is down!"
    /etc/init.d/apache2 restart
fi


web


Archives