User Tools

Site Tools


check_service_and_restart_if_failed

This is an old revision of the document!


Check service and restart if failed

Check the service if nginx is running and if not start

#!/usr/bin/env bash
 
# Enable System level logging
# Redirect log to logger
exec 1> >(logger -t $(basename $0)) 2>&1
 
STATUS="$(systemctl is-active nginx.service)"
 
if [ "${STATUS}" != "active" ]; then
   echo "Not running starting Service : Nginx"
   systemctl start nginx.service
fi
check_service_and_restart_if_failed.1595813299.txt.gz · Last modified: 2020/08/10 02:30 (external edit)