Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 5571  / 3 Years ago, fri, june 4, 2021, 11:17:18

Some BIOSes have an option to start the computer from a fully off state (not suspended) at a specific 'alarm' time. Is there any command or way to set this in Ubuntu without restarting and going to the BIOS?



(I have a server+router running for a school network and sometimes some random (well intentioned) people think it needs to be off at the end of the school day. I figure the best way to avoid getting calls at random times that the network quit working is to have a cron job every minute that sets the 'alarm wake' time as 2 minutes from now. That way it would auto start itself.)


More From » acpi

 Answers
6

Easy. First you need to check if your computer supports wake-up on RTC. Most computers created in the last 10 years support this feature. First you need to enable RTC in BIOS settings, this is done in the boot process. On my BIOS it's possible to configure what S-signals the wake-up should respond to. Because I like to save energy I completely let my computer power down in between automatic startups and shutdowns.



After BIOS is setup, boot up Linux and issue command dmesg |grep rtc. This tells you if you have RTC wake-up enabled. My output gives:



~$ dmesg |grep rtc
[ 0.962976] rtc_cmos 00:03: RTC can wake from S4
[ 0.963096] rtc_cmos 00:03: rtc core: registered rtc_cmos as rtc0
[ 0.963119] rtc0: alarms up to one month, 242 bytes nvram


To set the wakeup time you need to be root. As root issue command:



echo 0 > /sys/class/rtc/rtc0/wakealarm


The above command should be used before you write a new wake-up time to the file, otherwise the wake-up resource will be busy.
If you want your computer to start up in 10 minutes in the future issue command:



echo `date '+%s' -d '+ 10 minutes'` > /sys/class/rtc/rtc0/wakealarm


Check if alarm is set by issuing cat /sys/class/rtc/rtc0/wakealarm. If you get a bunch of digits it means that the alarm is set and if the file is empty there was something wrong with the date.



To check a more human readable format issue command cat /proc/driver/rtc.



So, if you want your computer to start 2 minutes after someone turns it off, execute a script that looks something like this from your crontab(this script will require root access, so be aware):



#!/bin/bash
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date '+%s' -d '+ 2 minutes'` > /sys/class/rtc/rtc0/wakealarm


Save the planet. :)


[#44736] Sunday, June 6, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
herriail

Total Points: 11
Total Questions: 122
Total Answers: 118

Location: Peru
Member since Tue, Mar 16, 2021
3 Years ago
herriail questions
Tue, May 18, 21, 02:11, 3 Years ago
Sun, Dec 12, 21, 06:06, 2 Years ago
Wed, May 24, 23, 01:42, 1 Year ago
Sun, Jan 29, 23, 00:48, 1 Year ago
;