#!/bin/sh ACTIVEFILE=/tmp/filldb.lck QRY="" QRY="$QRY SELECT ROUND((unix_timestamp(CURRENT_TIMESTAMP) " QRY="$QRY - unix_timestamp(data)) / 3600) " QRY="$QRY FROM settings " QRY="$QRY WHERE value = 'mythFillSuggestedRunTime'" # if the mythfilldatabase lockfile is present, then there is # a grab in progress. We don't need to check whether to run # now, for several reasons, including that we definitely # won't be overdue... if [ -f $ACTIVEFILE ]; then exit fi # figure out whether we're overdue. The return will be a number. # If negative then we have not yet reached the "recommended time" # If positive then the time has passed and we should force a run. TIMEDIFF=`echo "$QRY" | mysql -Dmythconverg --skip-column-names` if [ $TIMEDIFF -gt 0 ]; then # overdue. Run now. echo "RUNFILLDB: Overdue for mythfilldatabase. Running now." | logger #$HOME/bin/filldb2.sh /usr/local/bin/mythfilldatabase else echo "RUNFILLDB: Still [$TIMEDIFF] hours until next run." | logger fi