LinHES Forums http://forum.linhes.org/ |
|
Setting wakeup period to run mythfilldatabase http://forum.linhes.org/viewtopic.php?f=3&t=14530 |
Page 1 of 1 |
Author: | jbm2131 [ Sat Mar 10, 2007 3:11 pm ] |
Post subject: | Setting wakeup period to run mythfilldatabase |
Maybe this is overkill, but I thought I would post this. Maybe someone might find this useful. Since I am currently using the ACPI wakeup feature and don't have have my box on all the time, I could not run mythfilldatabase at the time suggested by the zap2it server. I know that you can manually set a specific time to run, but I thought it would be nice to have my box figure out when it needed to wake up to run mythfilldatabase at the suggested time. I created a script to run mythfilldatabase and then set a daily wakeup period in mythwelcome to turn on around the suggested time. I now just point to this script rather than mythfilldatabase (you set that on one of the "General" settings pages). I just completed one cycle through the whole timeline and it seems to be working. The part I have not tested completely is the code that adjusts the time so that the period does not cross midnight. Feel free to offer any suggestions or point out any flaws I overlooked. Code: #!/bin/bash
mythfilldatabase --quiet window=5 fill_str="MythFillSuggestedRunTime" start_str="DailyWakeupStartPeriod1" end_str="DailyWakeupEndPeriod1" mysql_cmd="mysql -u mythtv -pmythtv mythconverg" get_settab="SELECT value,data FROM settings" dbfilltime=$($mysql_cmd -e"$get_settab" | /bin/grep $fill_str | /bin/sed -e"s/^$fill_str\t//" -e"s/T/ /" ); runtime=$(/bin/date -d "$dbfilltime" +%s); # This stuff adjusts the suggested time because Mythwelcome currently # does not accept wake up periods that cross midnight suggesttime=$(/bin/date -d "$dbfilltime" +%H%M); if [ $suggesttime -ge $[2360-$window] ]; then runtime=$[runtime-$window*60] newtime=$(/bin/date -d "1970-01-01 UTC $runtime sec" +%FT%T); set_fill="UPDATE settings SET data='$newtime' WHERE value='$fill_str'" $mysql_cmd -e"$set_fill" elif [ $suggesttime -le $window ]; then runtime=$[runtime+$window*60] newtime=$(/bin/date -d "1970-01-01 UTC $runtime sec" +%FT%T); set_fill="UPDATE settings SET data='$newtime' WHERE value='$fill_str'" $mysql_cmd -e"$set_fill" fi start1=$(/bin/date -d "1970-01-01 UTC $[runtime-$window*60] sec" +%H:%M); stop1=$(/bin/date -d "1970-01-01 UTC $[runtime+$window*60] sec" +%H:%M); set_start="UPDATE settings SET data='$start1' WHERE value='$start_str'" set_end="UPDATE settings SET data='$stop1' WHERE value='$end_str'" $mysql_cmd -e"$set_start" $mysql_cmd -e"$set_end" BTW, this only works if you enable the "Auto-Start Front End" in mythwelcome and you disable the "Block Shutdown Before Client Connects" in mythtv-setup (General options). |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |