#!/bin/sh
SERVICE='named'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
cat /dev/null
else
echo "$SERVICE is not running... starting"
/etc/init.d/$SERVICE restart | mail -s "$SERVICE restarted" email@domain.tld
fi

p.s. do not name the script as the service 🙂

Leave a Reply

You must be logged in to post a comment.