On Fri, 15 May 2020 17:21:50 -0400, you 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:
>> Description=MythTV mythfilldatabase service.
>> And then create a file /etc/systemd/system/mythfilldatabase.timer:
>> Description=MythTV mythfilldatabase timer.
>> 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
>> 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
>> 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
>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.
One other thing I did not mention about cron jobs and systemd services
is that they do not get the usual environment variables. Since those
variables often point to paths for things, that can be a problem. In
the wrapper script I have that runs my EPG collection from cron, I
have this: # Set up a good environment for a cron job. This was created by
running the "at now + 1 hour" command on something, then going to the # /var/spool/cron/atjobs directory and copying the resulting script,
then using "atrm" to remove the at job. The SSL/TTY bits were
USER=stephen; export USER
MAIL=/var/mail/stephen; export MAIL
PWD=/home/stephen/.cron.daily; export PWD
LANG=en_NZ.UTF-8; export LANG
SHLVL=1; export SHLVL
HOME=/home/stephen; export HOME
LOGNAME=stephen; export LOGNAME
LESSOPEN=\|\ /usr/bin/lesspipe\ %s; export LESSOPEN
LESSCLOSE=/usr/bin/lesspipe\ %s\ %s; export LESSCLOSE
OLDPWD=/home/stephen/temp; export OLDPWD
The comment at the top shows how I got the settings necessary for
running a cron or systemd job. You can put the settings into a script
file, such as "epg.sh" and then run that from the cron or systemd job
that runs mythfilldatabase. So you then run mythfilldatabase from
epg.sh and run epg.sh from the cron or systemd job.
Also, run mythfilldatabase from where it works and look at its log
file to see what directory it is getting its configuration from. If
you can not find the log file, try adding "--logpath ." to the
mythfilldatabase command line to put the log file in the current
directory. Then look in the log for a line like this:
Using configuration directory = /home/stephen/.mythtv
I run mythfilldatabase from my mythfrontend user "stephen", rather
than from user "mythtv". But when mythfilldatabase is run by
mythbackend, it gets run using user "mythtv". So both those users
should have a config.xml file in their .mythtv directory. There can
be other files needed for each different XMLTV grabber. For example,
in my case I need a *.xmltv file for each video source. It is likely
that the mythfilldatabase log file will tell you each such file it
uses - my XMLTV grabber does that. If you have been running
mythfilldatabase manually from your mythfrontend user, it is likely
that both that user and the mythtv user will have those files, which
may be a problem. If you need to run mythfilldatabase manually as
well as from a cron/systemd job, then you should set up one user as
the place it gets run from, and in the other user's .mythtv directory,
use the "ln -s" command to link to the files needed under the other
user's directory. Make sure that the permissions are such that any
group "mythtv" user has full access to the files:
chown <local user name>:mythtv
or if it is a script or executable file or subdirectory:
To run a script from a systemd job:
ExecStart=/bin/bash -c "/home/mythtv/bin/epg.sh"
mythtv-users mailing list
email@example.com http://lists.mythtv.org/mailman/listinfo/mythtv-users http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org