[mythtv-users] Mythshutdown program

Bret Hughes bhughes at elevating.com
Sun Mar 5 14:42:58 UTC 2006


On Sun, 2006-03-05 at 04:01, Phill Edwards wrote:
> > 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

Phil - I wonder if this would not be a tad more efficient. I do not have
my box installed yet but have been lurking for a couple of days:
COMMFLAG='pgrep mythcommflag`
...

if [ ! "$COMMFLAG" ] ...

pgrep will return the pids of matching processes or null if not found. 
Then I think simply testing for untrueness should do the same thing as
what you are doing.

check out the pgrep man page for options.  Its kind of a neat command.

Bret





More information about the mythtv-users mailing list