[mythtv-users] does myth 'best practice' have me adding anything to cron?

Stephen Worthington stephen_agent at jsw.gen.nz
Wed Mar 23 05:10:45 UTC 2016


On Tue, 22 Mar 2016 20:30:06 +0000, you wrote:

>On March 22, 2016 5:26:36 AM GMT, steve <stevenospam at gmail.com> wrote:
>>Hi,
>>
>>I'm running Ubuntu 14.04 LTS with MythTV 0.27.6 installed via PPA, not
>>mythbuntu
>>
>>Am I supposed to be manually adding anything to cron for myth?
>>
>>For example, am I supposed to be crontabbing the running of
>>mythfilldatabase every so often?
>>
>>I found reference to some other cron files in some other thread, I am
>>guessing mythbuntu-desktop or maybe myth-control-centre created them?:
>>
>>/etc/cron.d/mythbuntu-bare
>>/etc/cron.daily/mythexport
>>/etc/cron.daily/mythtv-database
>>/etc/cron.daily/optimize_mythdb
>>/etc/cron.daily/optimize_mythdb.pl
>>/etc/cron.weekly/mythtv-database 
>>
>>Can someone post the contents of these so I can see what they do? 
>>
>>Thank you
>
>I too am running Ubuntu with mythtv packages installed on top, from the mythbuntu ppa, rather than installing from the mythbuntu ISO. I don't have mythbuntu-desktop installed, but do have mythbuntu-common, mythbuntu-bare-client and mythbuntu-control-center installed. I may have run mythbuntu-control-center in the past, but not for years.
>
>Of the cron entries you list, I have just:
>	/etc/cron.daily/mythexport
>	/etc/cron.weekly/mythtv-database 
>in my system. Using "dpkg -S" on the filenames, I see that /etc/cron.daily/mythexport comes from the mythexport package and /etc/cron.weekly/mythtv-database comes from the mythtv-database package. I suspect the people who have /etc/cron.daily/mythtv-database instead have manually moved the file from weekly to daily to make it occur more often.
>
>If you don't have the cron entries but do have the mythexport and mythtv-database packages installed, I'm guessing the files were manually deleted. If so, there is probably a proper way to reinstall or reconfigure the packages to bring the cron files back, but I don't know how to do that.
>
>John

mythbuntu-control-center is what installs the cron job for optimize.
If you want to install it manually, you can find optimize_mythdb.pl
here:

/usr/share/doc/mythtv-backend/contrib/maintenance

It is renamed to optimize_mythdb when installed in /etc/cron.daily by
mythbuntu-control-center.  Running optimize_mythdb daily is highly
recommended - doing so greatly reduces the likelihood of having
database problems.  Most people who have posted over the last few
years about having a problem with a database crash, when asked, had
not been running optimize_mythdb regularly.  It actually repairs
database errors even if they have not yet caused a problem.

Be aware that recent versions have this extra code at the bottom to
defragment various tables:

# Defragement seek table
    if ($dbh->do("ALTER TABLE `recordedseek` ORDER BY chanid,
starttime, type")) {
        print "Defragmented: recordedseek\n";
    }
# Defragement program table
    if ($dbh->do("ALTER TABLE `program` ORDER BY starttime, chanid"))
{
        print "Defragmented: program\n";
    }
# Defragement video seek table
    if ($dbh->do("ALTER TABLE `filemarkup` ORDER BY filename")) {
        print "Defragmented: filemarkup\n";
    }

With my massive database size (15235 recordings), I found that running
those commands caused recordings happening at the same time to be
corrupted (missing bits).  So I have commented out that code and now
occasionally run it manually when I am sure I have enough time between
recordings.

The /etc/cron.weekly/mythtv-database file is installed automatically
as part of the mythtv-database package.  I copied it to
/etc/cron.daily and altered it to do daily backups to another PC on my
network.  That way, I get weekly backups on my MythTV box, and daily
backups elsewhere.  I highly recommend daily backups as manually
fixing more than a day's worth of recordings after a database crash is
way too much.  If possible, it is best to have the database backups
going to another hard disk than the one the database itself is on, as
the backup process works the disk quite hard.  If the database is on
SSD, both on the same drive should be fine.

Make sure that the disk the database is backing up to has enough room
- the database backup works by exporting the entire mythconverg
database as SQL code to a text file, and then going back and
compressing that file with gzip.  So you need enough room for the
temporary SQL copy of the database (huge) and the compressed copy
(much smaller).  The default location for backups
(/var/lib/mythtv/db_backups) defaults to being on the main system
partition in normal Ubuntu/Mythbuntu installs.  That system drive is
often not too large, and as your database grows, it can fill the drive
and cause system crashes.  Putting the database backups on a recording
drive may be a better idea, as mythbackend will ensure that there is
always some free space on recording drives if it is allowed to do
autoexpire.  That is what I did with my weekly backups, as I always
ensure I have plenty of free space for new recordings and add new hard
drives as necessary to keep enough free space available.

The /etc/cron.daily/mythexport file is installed automatically as part
of the mythexport package, if you are using that.

I do not have a /etc/cron.d/mythbuntu-bare file, and I have no idea
what it would be for.


More information about the mythtv-users mailing list