I have been trying to get my desktop, also running mythtv to shutdown automatically and wake up again in the middle of the night if I have decided to record a program then.
I found a couple of issues with the two scripts that you have to make as described on the Wiki Page.
Firstly, a purely cosmetic issue, but I puzzled for a while why my logs for the wakealarm script were displaying the correct wake up time, but adding an hour to the time until wake up in the log.
I turned out that it uses date -d @$b +%HHrs:%MMins to display the gap. variable b holds the seconds between now and the wakeup time. What it is actually doing is displaying the time since Jan 1, 1970 at 00:00 UTC in local time and since I am currently in British Summer Time it is displaying an hour extra. What is needed is that command should be date -u d @$b +%HHrs:%MMins
However the more serious problem is that when nobody is logged in, the output of who -q is
So the script as quoted in the wiki page was never finding no-one logged in(unknown)
What I have done so far is the following:-
Code: Select all
XFCE_PROCS=`pgrep xfce` UNKNOWN_USER=`who -q | head -n 1 | sed 's/(unknown)//'` USERS=`who -q | tail -n 1 | sed 's/[a-z #]*=//'` if [ "$USERS" == "1" ] && [ "$UNKNOWN_USER" == "" ] && [ "$XFCE_PROCS" == "" ]; then echo $DATE No users are logged in, ok to shut down. exit 0 else echo $DATE Someone still logged in, don\'t shut down. exit 1 fi
Incidentally, the Wiki page also says that the output from this script goes into the logs, but I couldn't find it there. In the end I changed the pre-shutdown command to have >> /var/log/mythtv/checklogin.log appended to it, so it forced its output into a log