[mythtv-users] Mythfilldatabase

Stephen Worthington stephen_agent at jsw.gen.nz
Thu May 14 03:19:31 UTC 2020


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.


More information about the mythtv-users mailing list