[mythtv-users] 0.21 and database corruption/how to rebuild and update from backup
Bob Sully
rcs at malibyte.net
Wed Mar 19 05:31:18 UTC 2008
Neil Bird wrote:
> 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
>
Neil - thanks very much for posting this - you saved me some work - now I
don't have to reinvent the wheel. ;-) I'll modify it (if necessary) and
try it on my system. It hasn't crashed again since then, but even if it
happens again only rarely, it's still nice to have a fail-safe.
Ciao
Bob
--
________________________________________
Bob Sully - Simi Valley, California, USA
http://www.malibyte.net
http://www.malibyte.com
More information about the mythtv-users
mailing list