Below is a restart script for sendmail which will restart the
downed service and send email. You can modify this script to
check and monitor any service.
You can use this crontab to have this script run every 10 minutes
1,10,20,30,40,50 * * * * /usr/scripts/sendmail-check.sh > /dev/null 2>&1
# see if the service if running
COUNT=`ps waux |grep -v grep|grep -c sendmail`
# if the service if running quit
if [ $COUNT != 0 ]
echo $COUNT " is o.k. exiting..."
# if the service is not running...
echo "sendmail is down on server... Restarting...."
# politely stop and start the service
# e-page/e-mail someone so they will know there was a problem
cat /usr/scripts/problem.msg |mail -s "sendmail down on ns" firstname.lastname@example.org
Back to SALUG Main Page