[mythtv-users] mythfilldatabase run manually

Stephen Worthington stephen_agent at jsw.gen.nz
Thu Jan 9 14:18:14 UTC 2020


On Thu, 9 Jan 2020 06:32:39 -0500, you wrote:

>
>On 1/8/20 9:27 PM, Stephen Worthington wrote:
>> On Wed, 8 Jan 2020 14:30:03 -0500, you wrote:
>>
>>> I have a mobile combo mythtv FE/BE on a RPi4 in my RV.  So it only have an internet connection when I turn my phone into a hotspot and the wireless AP/router bridge reestablishes a connection to the hotspot. As a result when mythfilldatabase runs it usually doesn’t succeed.
>>>
>>> So  what I do now is:
>>> 1.  Turn on phone hotspot.
>>> 2.  Open terminal and ‘sudo su mythtv’ then ‘mythfilldatabase’
>>> 3.  Turn off phone hotspot.
>>>
>>> Anyone have a more automated way of doing this or is this the best I can hope for??
>>>
>>> Jim A
>> It is possible to get a script to run when a network connection comes
>> up - see /etc/network/if.up.  The system uses this, but it is possible
>> to add your own scripts also.  I presume an RPi also works this way -
>> it is a Debian and Debian based thing.  So you could have
>> mythfilldatabase run when a network connection comes up the first time
>> each day after the time it would normally be run.
>
>After more research I see that maybe setting a systemd service is best 
>and have that service run after network-online.target. Now I just need 
>to see if I can make a service that:
>
>1. runs everything the network comes up.
>
>2. only runs mythfilldatabase once per day.
>
>Jim A

Yes, systemd should be able to do it also.  But the
network-online.target is not what you want.  It comes up as soon as
one network interface is up, so that means it happens when localhost
comes up.  You could use my wait-until-pingable.py program to ping the
server that mythfilldatabase needs to talk to (if it is pingable).
Create a systemd unit like my local-network-pingable.service:

root at mypvr:/etc/systemd/system# cat local-network-pingable.service
[Unit]
Description=Wait for the local network to be pingable
After=network.target

[Service]
Type=simple
ExecStartPre=/bin/bash -c "/usr/local/bin/wait-until-pingable.py
switch.jsw.gen.nz 30"
ExecStart=/bin/true

[Install]
WantedBy=multi-user.target

but change its name and the server it pings.

Then you could create another systemd .service and .timer that runs
mythfilldatabase on a timer daily but also runs shortly after startup
if the time is already past the timer setting.  It would wait on your
<epgserver up>.service to know that the Internet was available.

You can download local-network-pingable.service and
wait-until-pingable.py from my web server:

http://www.jsw.gen.nz/mythtv/local-network-pingable.service
http://www.jsw.gen.nz/mythtv/wait-until-pingable.py

Here is an example of how I run a Python program twice a day (but also
just after  booting) to take my noisy recording drives out of the
storagegroup table at the times they would annoy me.

root at mypvr:/etc/systemd/system# cat noisy-drives.service
[Unit]
Description=MythTV noisy drives service.
Wants=mysql.service
After=mysql.service
Wants=mythtv-backend.service
After=mythtv-backend.service

[Service]
ExecStart=/root/projects/mythsgu/noisy-drives.py 00:00:00 09:30:00

[Install]
WantedBy=multi-user.target

root at mypvr:/etc/systemd/system# cat noisy-drives.timer
[Unit]
Description=MythTV noisy drives timer.

[Timer]
OnCalendar=02:30:00
OnCalendar=14:30:00
Persistent=true

[Install]
WantedBy=timers.target

The noisy-drives.py program is also available for download:

http://www.jsw.gen.nz/mythtv/noisy-drives.py


More information about the mythtv-users mailing list