Automatically start at specific time like BIOS?
Solution 1:
An operating system itself cannot bring hardware out of a completely-off state, as the OS is not running at that time. If there was any OS-level software to write to your BIOS, it would be proprietary software specific to the BIOS and motherboard etc., and highly unlikely to exist as an ubuntu command. Sorry.
BIOS options such as Wake On Lan, or your auto-start feature are one option. The other is a hardware solution similar to what some tv tuner cards do by getting hard wired into the power button in order to trigger power-on events. In cases like this, cron job could be used to constantly update the wake-time for the tuner card.
Solution 2:
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. :)