[mythtv-users] 0.21 and database corruption/how to rebuild and update from backup

Neil Bird neil at fnxweb.com
Tue Mar 18 08:38:51 UTC 2008


Around about 18/03/08 05:27, Bob Sully typed ...
> One minor concern...  The backend segfaulted, and I had to restart
> it manually.  Hopefully that won't happen again.  I'm wondering if maybe I
> should write a little script (if there isn't one already out there) to
> check every so often whethere the backend is running, and if not, restart
> it...?

   As I'm paranoid, and it does stuff up sometimes, I have (among other 
entries for mythfilldatabase and LCD status):

[/etc/cron.d/mythtv]
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
MAILTO=root at mymainbox
HOME=/

*/5 * * * * root        /usr/local/bin/check-mythbackend


   And the script (now this may look a little odd but I figured, for no good 
reason, really) that 12 cron runs an hour with 5 checks apiece was better 
that 60 runs an hour:

[/usr/local/bin/check-mythbackend but edited to remove some other stuff]
#!/bin/bash

shopt -s nullglob
doit=false

# Need to start mythbackend?
if [ -e /var/run/mythbackend.pid ]; then
         pid=`cat /var/run/mythbackend.pid`
         if [ ! -e /proc/$pid ]; then
                 rm -f /var/run/mythbackend.pid
                 doit=true
         fi
fi

$doit && /sbin/service mythbackend start 2>&1 >/dev/null  &

doit=false


# Check 4 more times
for attempt in 1 2 3 4; do
         sleep 60
         doit=false
         # Need to start mythbackend?
         if [ -e /var/run/mythbackend.pid ]; then
                 pid=`cat /var/run/mythbackend.pid`
                 if [ ! -e /proc/$pid ]; then
                         rm -f /var/run/mythbackend.pid
                         doit=true
                 fi
         fi
         $doit && /sbin/service mythbackend start 2>&1 >/dev/null  &
done


   YMMV.

-- 
[neil at fnx ~]# rm -f .signature
[neil at fnx ~]# ls -l .signature
ls: .signature: No such file or directory
[neil at fnx ~]# exit


More information about the mythtv-users mailing list