Настойка включения компьютера по расписанию, а также выключение его бакендом - Имеем Ubuntu 10.04, мать Asus A8N-VM (GF6100), MythTv 0.23
В БИОСе - Suspend Mode - Auto
ACPI 2.0 - Enabled
ACPI APIC - Enabled
Power On By RTC Alarm - Disabled
Системное время в UTC.
/etc/init/hwclock-save.conf вот такой -
# hwclock-save - save system clock to hardware clock
#
# This task saves the time from the system clock back to the hardware
# clock on shutdown.
description "save system clock to hardware clock"
start on runlevel [06]
task
script
. /etc/default/rcS
[ "$UTC" = "yes" ] && tz="--utc" || tz="--localtime"
[ "$BADYEAR" = "yes" ] && badyear="--badyear"
#exec hwclock --rtc=/dev/rtc0 --systohc $tz --noadjfile $badyear
end script
В sudoers добавляем :
%mythtv ALL=NOPASSWD: /sbin/shutdown, /sbin/halt, /bin/sh, /usr/bin/setwakeup.sh, /usr/bin/mythbackend, /usr/bin/mythshutdown
%vr ALL=NOPASSWD: /sbin/shutdown, /sbin/halt, /bin/sh, /usr/bin/setwakeup.sh, /usr/bin/mythbackend, /usr/bin/mythshutdown
Вместо vr конечно ваш логин.
Настройки бакенда -
Общие - Настройки завершения -
1. Блокировать завершение пока есть клиенты - ДА
2. Idle shutdown timeout (sec) - 180
3. Максимальное ожидание для записи (мин) - 120
4. Запуск перед записью (сек) - 180
5. Формат времени побудки - time_t
6. Command to set wakeup time - sudo sh -c "/usr/local/bin/setwakeup.sh $time"
/usr/local/bin/setwakeup.sh такой -
#!/bin/sh
#$1 is the first argument to the script. It is the time in seconds since 1970
#this is defined in mythtv-setup with the time_t argument
echo 0 > /sys/class/rtc/rtc0/wakealarm #this clears your alarm.
echo $1 > /sys/class/rtc/rtc0/wakealarm #this writes your alarm
7. Команда завершения сервера - sudo /sbin/halt -p
8. Команда проверки перед завершением - /usr/local/bin/MythShutdownCheck
/usr/local/bin/MythShutdownCheck такой -
#
# MythShutdownCheck
#
# checks to see if any other user is
# logged in before idle shutdown
#
# returns "1" if yes, stopping shutdown
# returns "0" if ok to shutdown
#
# to not shutdown during mythcommflag process, uncomment the following line
# ps ax | grep -v grep | grep -q mythcommflag && exit 1
ps ax | grep -v grep | grep -q xbmc && exit 1
if last | head | grep -q "pts/.*still logged in" # check for active *remote* login?
then
exit 1
else
exit 0
fi
конечно сточку с xbmc можно закоментить, или вписать другую прогу которая буде блокировать выключение.
Вот и все! Теперь комп включается, записывает, если в ближайшие 2 часа не ожидается новых записей и не запущен фронтенд ( или xbmc у меня), то выключается через 3 минуты.