[mythtv-users] How do I create a mythbackend watchdog timer?

Allen Edwards allen.p.edwards at gmail.com
Tue Aug 18 21:01:32 UTC 2009


On Tue, Aug 18, 2009 at 1:16 PM, Allen Edwards<allen.p.edwards at gmail.com> wrote:
> In another thread, it was pointed out that mythbackend crashes
> periodically and there is nothing I can do about it until it is
> debugged.  So, I want to create a timer that will restart if if it has
> crashed becasue I don't want my marriage to crash along with
> mythbackend.
>
> There seem to be a ton of opinions on how to do this along with lots
> of notes to change this or that line if it causes problems.  Someone
> must be doing this and have an opinion on what works.  The email
> feature would be great if that works out of the box but in any event
> some monitoring that something happened.
>
> I found this, which has several options
> http://www.mythtv.org/wiki/StatusMonitoringHowTo
>
> And this
> http://www.avsforum.com/avs-vb/archive/index.php/t-917406.html
>
> Before I try all these, what works?  I am running mythbuntu 8.04
>
> Allen
>
>
>



I found this and wonder if this is this a good way?

Put this in /etc/cron:
# Run every minute and restart mythbackend if it has crashed

* * * * * root /usr/bin/mythmon

and this in /usr/bin with "sudo chmod 755 /usr/bin/mythmon"

#!/bin/bash
LOG=/var/log/mythtv/mythbackend.log

date "+%Y-%m-%d %H:%M:%S Checking" >> /tmp/mythmon.log

if ! ps -ef | grep [m]ythbackend >/dev/null; then

  # Check whether setup utility is running
  if ps -ef | grep [m]ythtv-setup >/dev/null; then
    date "+%Y-%m-%d %H:%M:%S mythtv-setup running" >> /tmp/mythmon.log
    exit 0
  fi

  # Mythbackend has crashed, log and restart
  date "+%Y-%m-%d %H:%M:%S Crash detected - restarting mythbackend" >> $LOG
  date "+%Y-%m-%d %H:%M:%S Crash detected - restarting mythbackend" >>
/tmp/mythmon.log
  chown mythtv:mythtv $LOG
  /etc/init.d/mythtv-backend restart
fi

Allen


More information about the mythtv-users mailing list