[mythtv-users] Mythshutdown program

Phill Edwards philledwards at gmail.com
Sun Mar 5 10:01:22 UTC 2006


> Before upgrading my mythtv install to 0.19 I would like to know if it's
> possible to know when the backend is recording or watching a record. I've
> done some tests and it seems that is impossible.

I have this script:

#!/bin/sh
# This prog returns 1 back to the myth auto-shutdown checking if
# commercials are being flagged, or a prog is being transcoded or if tv
# listings are being grabbed. 1 prevents auto-shutdown, 0 allows it to proceed.

# To quickly prevent auto shutdown comment in the following exit 1
line or put 1 in
# /home/mythtv/.mythtv/mythpreshut. To allow proper shutdown checks and
# processing, comment it out.
#exit 1

COMMFLAG=`ps -e | grep mythcommflag | grep -v grep | wc -l | awk '{print $1}'`
TRANSCODE=`ps -e | grep mythtranscode | grep -v grep | wc -l | awk '{print $1}'`
TV_GRAB=`ps -e | grep tv_grab_au.sh | grep -v grep | wc -l | awk '{print $1}'`
NUVEXPORT=`ps -e | grep nuvexport | grep -v grep | wc -l | awk '{print $1}'`
#NO_SHUT=`ps -e | grep noshut | grep -v grep | wc -l | awk '{print $1}'`
NO_SHUT=`cat /home/mythtv/.mythtv/mythpreshut`

if [ $COMMFLAG -eq 0 ] && [ $TRANSCODE -eq 0 ] && [ $TV_GRAB -eq 0 ]
&& [ $NUVEXPORT -eq 0 ] && [ $NO_SHUT -eq 0 ]
then
       echo "`date +%F\ \%T` No jobs running, auto-shutdown allowed"
>> /var/log/mythtv/mythbackend.log
       exit 0
else
       echo "`date +%F\ \%T` Something's running, auto-shutdown
disallowed" >> /var/log/mythtv/mythbackend.log
       exit 1
fi

Sounds like sort of what yuo're looking for.

Regards,
Phill


More information about the mythtv-users mailing list