Browse - Computer Tips - How can I restart a service/daemon when it dies?
Warning: This doesn't work with systemd
Q. How can I restart a service/daemon when it dies?
A. Of course, its best to locate the reason why its dying. But
as a Bandaid you can do this.
If your service MYSERVICE is at issue make file /etc/cron.hourly/check_MYSERVICE that contains:
if /sbin/service MYSERVICE status | grep -q 'is running'; then
echo "MYSERVICE seems to be down -- restarting"
/sbin/service MYSERVICE restart
And make it executable:
chmod a+x /etc/cron.hourly/check_MYSERVICE
You'll get mail when it restarts the service (no mail when checks it and its OK).
You can do this for multiple services.