If your Linux service is not running?

Our task is service checking and restart that service if it's not running.

For example, MySQL:


#!/bin/bash
service="mysqld"

if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi