[mythtv-users] Automatically restart backend on failure? (Gentoo)

Asher freedenizen at gmail.com
Tue Oct 31 23:25:57 UTC 2006


On 10/31/06, Andrew Lyon <andrew.lyon at gmail.com> wrote:
> Hi,
>
> Anybody know of a way to make mythbackend automatically restart if it
> crashes? I'm running Gentoo and myth 0.20 11607.
>
> I can think of ways to do it, but perhaps I am missing the obvious and
> there is a easy way already in gentoo?
>
> Andy

I forget where I got this from but I have a cron entry for this:
*/1 * * * * /usr/local/bin/backend_check.sh
so backend_check.sh runs every minute

contents of backend_check.sh
#!/bin/bash

# Test to see if process is running first
if ps -ef|grep -v grep|grep mythbackend
then
        echo "backend found"
else
        echo "BACKEND CRASHED" >> /var/log/mythbackend.log
        /etc/init.d/mythbackend stop
        /etc/init.d/mythbackend zap
        /etc/init.d/mythbackend start
fi
exit


So it looks for the mythbackend processes, if it doesn't find it it
try to run stop through the init script which will usually fail so it
runs zap to manually set the state of the process to stopped, then it
starts it.  It also writes "BACKEND CRASHED" to my mythlog so I can
easily look and see when and if this has occurred.  It is a bit of a
hacky way to do it, but it was quick.


More information about the mythtv-users mailing list