{"id":103,"date":"2006-05-04T19:33:30","date_gmt":"2006-05-05T03:33:30","guid":{"rendered":"http:\/\/outflux.net\/blog\/archives\/2006\/05\/04\/mythtv-listing-update-time-rotation\/"},"modified":"2006-05-04T19:33:30","modified_gmt":"2006-05-05T03:33:30","slug":"mythtv-listing-update-time-rotation","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2006\/05\/04\/mythtv-listing-update-time-rotation\/","title":{"rendered":"mythtv listing-update time-rotation"},"content":{"rendered":"<p>A few months ago, <a href=\"http:\/\/www.zap2it.com\/\">zap2it<\/a>&#8216;s renewal survey included a set of questions that were not questions, but rather pleas that people move their database updates to a non-standard time.  The default install of MythTV has a hard-coded time in the middle of the night to contact the zap2it servers for TV listing updates.  Unfortunately, this means zap2it&#8217;s servers were (are?) getting crushed on the hour, across 4 time-zones, in the middle of the night.<\/p>\n<p>To solve this little problem in MythTV, I turned off the built-in &#8220;mythfilldatabase&#8221; execution, and moved to doing it via crontab.  zap2it said they had virtually no load during the day-time, so I moved the update to a little after noon, sticking the following in <code>\/etc\/cron.d\/mythtv-backend<\/code>:<\/p>\n<blockquote><p>09 12     * * *     mythtv   mythfilldatabase &#8211;quiet<\/p><\/blockquote>\n<p>It dawned on me today while messing around with the &#8220;at&#8221; scheduler that I could actually randomize when during the day the mythfilldatabase runs.  If you wanted to run the job anywhere in a 12 hour (720 minute) period after 9am, you could do it this way:<\/p>\n<blockquote><p>0 9 * * *     mythtv echo &#8220;mythfilldatabase &#8211;quiet&#8221; | at + $(( RANDOM % 720 )) minutes<\/p><\/blockquote>\n<p>(My bash manpage says the low-order bits of $RANDOM are as random as the high-order bits, so this is &#8220;safe&#8221;.  If you don&#8217;t trust your version of bash, you could use $(( 720 * RANDOM \/ 32767 )) instead.  IANAMG*, YMMV, OMGPONIES.)<\/p>\n<p><em>*I Am Not A Math Geek<\/em><\/p>\n<p style='text-align:left'>&copy; 2006, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few months ago, zap2it&#8216;s renewal survey included a set of questions that were not questions, but rather pleas that people move their database updates to a non-standard time. The default install of MythTV has a hard-coded time in the middle of the night to contact the zap2it servers for TV listing updates. Unfortunately, this [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/103"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":0,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}