[mythtv-users] Sleep and wake up scripts to extend MythTV Backend functionality

Craig Huff huffcslists at gmail.com
Sun Apr 6 21:54:38 UTC 2014


I have done something similar, although I don't tie it in with cron jobs.

I have tasks I do when the system is going down, such as optimizing
the db, making a db backup, checking for impending fscks, and
regenerating the folder of human-readable file names for the
recordings.  Some of these I only want to do once a day, others
whenever I shutdown.

I have myth call a script of mine instead of directly calling
"mythshutdown --check".  My script checks with mythshutdown and
immediately returns the "no" value ("1"?) if mythshutdown says no.  It
continues to check other things if mythshutdown thinks it is ok to
shutdown.  Things I check for: mythfilldatabase is running, there are
tty connections implying terminal sessions, the system has only been
up a short while and the sluggish human hasn't had time to tell it to
stay up please, the file /var/log/mythtv/housekeeping_needed exists,
or the file /var/log/mythtv/housekeeping_in_progress exists, etc.

I have an anacron job that creates the housekeeping_needed file once a
day.  When my ShutdownCheck script finds that file, it deletes it,
replaces it with housekeeping_in_progress and launches a housekeeping
script in the background (e.g. # housekeeping &).  In the meantime it
tells the system to stay up while housekeeping is taken care of.

The housekeeping script then does time consuming things like
optimizing the db, making a new backup of the db, and anything else
that I want to do once a day -- my system is definitely up more than
once a day ;-).

Once the ShutdownCheck script is satisfied, I configured myth to call
another script of mine to do other things at shutdown time.  In
particular, I check if it is about time to run fsck on my system and
do it now while the system isn't going to be needed for more time than
the fsck will take.  If it is time to run fsck, I touch the
appropriate file (/force_fsck, IIRC) and then do a "shutdown -r now"
to get'er done, otherwise it ends up invoking "shutdown -h now".

I am thinking of changing some of this to take advantage of
autobackup.sh, but I have other things to fix up first.

--
Craig.


More information about the mythtv-users mailing list