#!/bin/bash
MYTH_RUN_STATUS=1
. /etc/profile

date=`date +%Y-%m-%d`
timestamp=`date +'%Y-%m-%d %H:%M'`
logFile="/var/log/$date/myth_mtc.log"

if [ ! -f $logFile ]; then
    touch $logFile
fi

#check logfile for Finished and if not run myth_mtc.py
if ! grep -q "Finished" $logFile
then
    MYTHCONFDIR=/usr/share/mythtv unbuffer myth_mtc.py >> $logFile 2>&1
    if [ $? = 0 ]
    then
        echo "Finished $timestamp" >> $logFile
    else
        echo "Time Exceeded $timestamp" >> $logFile
    fi
fi