[mythtv-users] Mythfilldatabase

Bill Meek keemllib at gmail.com
Fri May 15 21:46:11 UTC 2020


On 5/15/20 4:21 PM, Matthew Daubenspeck wrote:
> On Thu, May 14, 2020 at 03:19:31PM +1200, Stephen Worthington wrote:
>> On Wed, 13 May 2020 14:25:05 -0400, you wrote:
>>
>>> Just recently updated to mythtv 31.0 on Arch Linux. I moved the
>>> SchedulesDirect setup to tv_grab_zz_sdjson and am having a very strange
>>> thing happen which I can't figure out.
>>>
>>> If I run mythfilldatabase manually at the commandline, everything works
>>> perfectly. If I add it to a cron job, it fails with the following error:
>>>
>>> tv_grab_zz_sdjson  --capabilities failed or we timed out waiting. You
>>> may need to upgrade your xmltv grabber
>>>
>>> Grabbing XMLTV data using tv_grab_zz_sdjson is not supported. You may
>>> need to upgrade to the latest version of XMLTV.
>>>
>>> Again, it works perfectly, as long as it isn't run from cron and I can't
>>> figure out why. Any suggestions?
>>
>> That sounds like the classic problem of cron running jobs as root, and
>> mythfilldatabase needs to be run from your mythtv user normally.  If
>> you are any good at systemd, you might like to consider running
>> mythfilldatabase as a systemd timer unit - systemd makes it easy to
>> run things as different users.
>>
>> Here is what I think a systemd setup to run mythfilldatabase as the
>> mythtv user should look like.  Note that I have not tested this:
>>
>> Create a file /etc/systemd/system/mythfilldatabase.service:
>>
>> [Unit]
>> Description=MythTV mythfilldatabase service.
>> Wants=mythtv-backend.service
>> After=mythtv-backend.service
>>
>> [Service]
>> User=mythtv
>> Group=mythtv
>> Type=simple
>> ExecStart=/usr/bin/mythfilldatabase
>>
>> [Install]
>> WantedBy=multi-user.target
>>
>> And then create a file /etc/systemd/system/mythfilldatabase.timer:
>>
>> [Unit]
>> Description=MythTV mythfilldatabase timer.
>>
>> [Timer]
>> OnCalendar=15:10:00
>> Persistent=true
>>
>> [Install]
>> WantedBy=timers.target
>>
>> Those files need to be chown root:root and chmod u=rw,g=r,u=r.
>>
>> Change the OnCalendar= setting to whenever you want mythfilldatabase
>> to be run.  You can have as many OnCalendar= lines as you like.
>>
>> The do these commands:
>>
>> sudo systemctl daemon-reload
>> sudo systemctl enable mythfilldatabase.service
>> sudo systemctl enable mythfilldatabase.timer
>> sudo systemctl start mythfilldatabase.timer
>>
>> If you want to manually run mythfilldatabase:
>>
>> sudo systemctl start mythfilldatabase.service
>>
>> If you only want mythfilldatabase to be run at the time specified, and
>> not at boot time if the timer was missed, then do not enable the
>> mythfilldatabase.service.
>>
>>
>> The way to run cron jobs as different users is to change your command
>> prompt to that user:
>>
>> su -l mythtv
>>
>> and then run:
>>
>> crontab -e
>>
>> That puts you in your default command line editor (nano in my case) on
>> the crontab file for that user.  Put your mythfilldatabase cron job
>> there, save and exit.  Remove the anacron job from /etc/cron.daily or
>> wherever you currently have it.
>>
>> Note that user cron jobs are cron jobs, not anacron jobs.  They are
>> run at the time specified only, and are not queued and run in sequence
>> with other jobs as cron.daily jobs are.  And they do not get run
>> automatically at boot if the time was missed due to the PC being shut
>> down.
>>
>> My mythfilldatabase runs from my user crontab, as I have been running
>> it there since well before Ubuntu changed to systemd.
>> _______________________________________________
> 
> I'm about to throw something!
> 
> I've tried multiple cron settings, like you suggested, and get the same
> results. My normal user runs mythtv-setup, and has run mythfilldatabase
> for years just fine, until the change to the SD JSON grabber. I tried
> the systemd method as well, it gets the same error:
> 
> tv_grab_zz_sdjson  --capabilities failed or we timed out waiting...
> 
> I've tried scripts running as other users, I've read and re-read both
> replies to my original message, as well as both wiki articles on xmltv
> and mythfilldatabase. Neither of them seem to make a difference.
> Everything runs fine when I run them manually, but as soon as cron is
> involved, it errors out and doesn't work.
> 
> I copied all of the .mythtv and .xmltv directories to a newly created
> mythtv home directory, and again, it runs fine if I do so manually. But
> add it to cron, or your systemd suggestion, and it errors out the same
> way.
> 
> I'm almost to the point of having another machine run a cronjob over ssh
> just to get it to work.
> 
> I also tried sudo --set-home --login --user=mythtv ... but I guess I
> don't understand what the ... should be, as any command I use there does
> nothing and returns to the prompt.
>

By ..., I meant any MythTV command. For example, mythfilldatabase.
Or, at setup time, the tv_grab_zz_sdjson commands. That way the
command runs as user mythtv and you don't need extra files.

Actually, I recall you mentioning tv_grab_zz_sdjson_sqlite earlier.
You must choose one.

As to copying ~.mythtv/blah.xmltv and ~/.xmltv/SchedulesDirect.DB,
be sure the blah.xmltv file points to a single database. The one
under your user is fine. Just don't have two! And, the directories
must be writable by any user that attempts to change them.

Adjust as required if tv_grab_zz_sdjson is really being used.

-- 
Bill


More information about the mythtv-users mailing list