Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2010jun1 OS: Linux Language: bash 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:#!/bin/sh if /sbin/service MYSERVICE status | grep -q 'is running'; then : else echo "MYSERVICE seems to be down -- restarting" /sbin/service MYSERVICE restart fiAnd make it executable:chmod a+x /etc/cron.hourly/check_MYSERVICEYou'll get mail when it restarts the service (no mail when checks it and its OK). You can do this for multiple services.
Add a commentSign in to add a comment