I need to monitor the status of nagios service (Because, whenever I make any changes in configuration and apply the new configuration, I would find nagios service stopped).If found in 'stopped' state, it should get started automatically.I tried writing a small shell script and added it to cron, but found that the script would execute every time even if the service is running. The script is:#!/bin/bashservice nagios status | grep runningif [ $? -ne 0 ]then        service nagios startfiWhenever the service is in 'stopped' state, the output of service nagios status shows No lock file found in /usr/local/nagios/var/nagios.lock. Should I monitor the /usr/local/nagios/var/nagios.lock file using inotify-tools or is there some better alternative to this?
Keeping track of service status continuously
linux;cron;services