Automatically sleep and wake a Linux machine

My htpc is powered on 24 hours a day but I’m using it just a few. I hate wasting power, but I’m a bit lazy at the same time. So manually shutting down and booting wasn’t an option. Luckily there’s rtcwake.

Rtcwake can not only trigger a shutdown, sleep or hibernate but even a wake from those powerstates. You’re reading it right, your machine will automatically boot when it’s turned off. Using it is plain simple:

Immediately go to standby and automatically wake after 60 seconds (S1)

rtcwake -m standby -s 60

Immediately go to sleep and automatically wake after 60 seconds (S3)

rtcwake -m mem -s 60

Immediately suspend to disk and automatically wake after 180 seconds (S4)

rtcwake -m disk -s 180

Fully power down and automatically wake after 8 hours.

rtcwake -m off -s 28800

One little remark: make sure your BIOS time settings are correct.