[mythtv-users] Backend no-longer shuts down after yesterdays update...

Douglas Peale Douglas_Peale at comcast.net
Sat Oct 5 02:54:36 UTC 2013


On 10/04/2013 07:41 PM, Bill Meek wrote:
> On 10/04/2013 09:32 PM, Douglas Peale wrote:
>> I updated yesterday, 0.27 was updated again yesterday, I noticed that last night my backend did not shut down, and again today
>> it did not shut down while I was at work.
>>
>> I checked my logs, and found that the script that I have it run to check to see if it is OK to shut down is no-longer being run,
>> and in fact last ran before I updated.
>>
>> I checked the backend setup, and the setup appears correct.
>>
>> Did a new option show up that I need to enable?
>
> I didn't have to change anything for my Pre Shutdown
> Wakeup Script to run. Is it returning a failure?
>
> Can you run it on the command line then type: echo $?
> to see what it's returning?
>
> Use mythbackend --serverbose system to see it run.
> The timing has changed a bit. Whatever you set your
> shutdown time to, e.g. 180 seconds, it will now take
> about 2 minutes more.
>
> Or, did you check the release notes for the option
> changes in mythshutdown (if that's part of your script.)
>
script has not changed, still runs fine.

It logs to a file in the /temp directory. I deleted this file before I sent my previous e-mail to this list. when I ran the
script from the command line, it created this file again, and it now contains exactly one entry.

The return value was 1, but that is what it is supposed to be since the purpose of the script is to prevent shutting down when a
user is logged in and using the computer.

This is it in its entirety:
#!/bin/bash
# Check to see if there are reasons MythTV does not know about to prevent shutdown. Return zero if not and 1 if so.
# Echoed text appears in log file. It can be removed and --quiet added to the
# grep command once you are satisfied that mythTV is working properly

# Customizable variables
MIN_UPTIME=10   # Minimum up time in minutes
# End of customizable variables

# Get a date/time stamp to add to log output
DATE=`date +%F\ %T\.%N`
DATE=${DATE:0:23}


UPTIME=`cat /proc/uptime | awk '{print int($1/60)}'`

echo ck-list-sessions >>/temp/checklogin.log
ck-list-sessions >>/temp/checklogin.log

if [ "$UPTIME" -lt "$MIN_UPTIME" ]; then
    echo $DATE Machine uptime less than $MIN_UPTIME minutes, don\'t shut down. >>/temp/checklogin.log
    echo $DATE Machine uptime less than $MIN_UPTIME minutes, don\'t shut down.
    exit 2
fi

  if (who -q | grep "users=0") || (ck-list-sessions | grep "realname = 'Gnome Display Manager'") ; then
    echo No one is logged in. >>/temp/checklogin.log
    echo No one is logged in.

         # If the user event is currently executing, do not shut down
         # IMPORTANT! you must change the text in the quotes to match the name of the program/script your are running with cron!
      if ps -A | grep "testscript" ; then
        echo $DATE User script is still running, don\'t shut down. >>/temp/checklogin.log
        echo $DATE User script is still running, don\'t shut down.
        exit 1
      fi

      #I don't know how to ask MythTV for these values, so I must duplicate them here. This is ugly
    maxwait=3600

      #Calculate time_t format time for next non MythTV event. Note that this time is hard coded
      # This time must match the time of the scheduled event in cron.
    userevent=$(date -d 3:00AM +%s)
    currenttime=$(date +%s)
    (( userevent += ( ( userevent + 5 ) < currenttime ) ? 24*60*60 : 0 )) # if userevent time has already passed, add 1 day.

        #if there is plenty of time before event, allow shutdown
      if (( currenttime < ( userevent - maxwait ) )); then
        echo $DATE User script is not running and there is lots of time before it needs to start, shut down. >>/temp/checklogin.log
        echo $DATE User script is not running and there is lots of time before it needs to start, shut down.
        exit 0
      else
        echo $DATE User script is not running, but it will start shortly, don\'t shut down. >>/temp/checklogin.log
        echo $DATE User script is not running, but it will start shortly, don\'t shut down.
        exit 1
      fi
   
  else
    echo $DATE Someone is still logged in, don\'t shut down!  >>/temp/checklogin.log
    echo $DATE Someone is still logged in, don\'t shut down!
    exit 1
  fi


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://www.mythtv.org/pipermail/mythtv-users/attachments/20131004/d071143e/attachment.sig>


More information about the mythtv-users mailing list