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

Stephen Worthington stephen_agent at jsw.gen.nz
Thu Mar 24 05:03:20 UTC 2016


On Wed, 23 Mar 2016 23:39:03 -0400, you wrote:

>Speaking of mysql, what is the proper way to restart mysql on myth?
>
>Say I need to restart mysql for non myth related reasons...
>
>I do 
>
>sudo /etc/init.d/mysql restart
>
>But I presume in this case I need to shudown the backend first, right?  What's the command line way to do that?
>
>And secondly, speaking of corruption, whats the sanctioned way of restarting a myth box?
>
>Now I do a sudo reboot
>
>Is that OK?
>
>Or am I supposed to be using a myth provided shutdown routine?  Because somewhere in the settings, I saw something about shutting down with different pre/post stages or something.

The right way to shut down and restart things depends on your
operating system, rather than MythTV.  It varies from distro to distro
and differs in different versions even of the same distro, as the
distro evolves.

In Ubuntu 14.04, there are two different ways of doing things - those
programs that support Upstart, and those that only do it the old way
from /etc/init.d.  If the program supports Upstart, the control file
for it will be found in /etc/init.  It may also still have a
/etc/init.d file, but you should ignore that if it has an /etc/init
file.  For programs that use Upstart, such as mythbackend and mysqld,
you need to use the upstart commands.  The base Upstart command is
initctl.  For convenience, there are shortcut links to initctl from
start, stop, status, reload and restart commands, which perform
"initctl start", "initctl stop", ... commands.  The name of the task
to give in an initctl command is found by using the "initctl list"
command or looking through the file names in /etc/init.  Here is the
output of the command "initctl list | grep my" on my Mythbuntu 14.04
system:

root at mypvr:/etc/init# initctl list | grep my
mysql start/running, process 3160
mythtv-backend start/running, process 7820

So the command to stop mythbackend is:

  stop mythtv-backend

And for mysqld, the command is:

  stop mysql

Strictly speaking, it is best to shut down mythbackend before shutting
down or restarting mysqld, but in fact mythbackend is extremely
tolerant of mysql errors, so if mythbackend is not recording or
otherwise busy (eg processing EPG), then restarting mysqld without
stopping mythbackend normally causes no problems as the restart is
rapid enough that mythbackend will just retry a mysql command that
fails while mysqld is gone.

Using the reboot command to restart a Ubuntu/Mythbuntu box works just
fine, as the Upstart system and the old /etc/init.d files are used to
shut down everything in an orderly manner.  GUI programs (eg Firefox)
will complain about being killed without being shut down properly as
they do not participate in the Upstart or /etc/init.d system, so it is
best to manually shut them all down first.  There is also an option in
mythfrontend to do a restart or shutdown from there.  When you use the
Back command (Esc) from the main menu in mythfrontend, it brings up a
menu saying "Do you really want to exit MythTV?".  That has four
options:

  No
  Yes, Exit now
  Yes, Exit and reboot
  Yes, Exit and shutdown

The bottom two options may not be shown unless you set the right
settings option to make them visible - sorry, I do not remember where
that option is at present.  Those two options normally run the correct
reboot and shutdown commands for your system, and are configured as
such by default with the Mythbuntu packages, but the command that is
run can be changed in the settings.  On other distros, I do not know
if they get configured correctly by default.

Be aware that as from 15.10? (I think), Ubuntu is now using systemd
instead of Upstart.  So when you upgrade to 16.04, the commands all
change.  I think they become "service stop", and the control files are
in a different place and work completely differently once again.  But
I have not tried a systemd based system myself yet, so I do not know
much about it yet.


More information about the mythtv-users mailing list