Have you ever wanted to shutdown, then power on in specified time your computer? And what’s about energy bills?
At the moment I have a nominal ~60W home-server consumer. Not a high consumption (very low! A nominal server consume at least ~200W) but if you calculate it to 1 month –> 60(Watt) X 24(Hour) X 30 (day) / 1000 = 43,2 kWh. With 6h pause (shut down server) I can save ~10,8kWh/month. If I calculate with 200W –> ~140,6kWh, I can save 36kWh/month with 6h pause. So if you are old enough, you know that this can be used for better target / month.
I knew these but because my server is in loft & I’m a very leisurely man I skip the option to take this action by hand. The other option that I use WOL (Wake On Lan) for this task is an another usable solution, but I found a better way. Now I will explain it.
When & Where this solution will be good for you?
Not in every situation can be used this solution. For me it is not problem if server is not reachable during my family sleep but for web-hosting / file-sharing I do not recommend as you can’t determinate exact time-frame when nobody uses services on server.
- You can determinate time-frame when nobody use server.
- You don’t have local physical access for server.
Which tool / function will be used?
RTC-alarm will be your friend. This feature was implemented long-time ago (~y2k) to computer’s BIOS, so you have a chance that your motherboard & BIOS also support it. RTC is NOT EQUAL with system clock! System clock is a software solution with timezone & format possibilities while RTC is a hardware solution which is work in power off state also (coil-cell in computer is the source of energy of it). While your computer is in power off state RTC count the time & when you power it again, system-clock’s base is RTC.
Wake On Lan also a good possibility, but it requires more “energy” for task. You must to have an another device, which can generate magic-packets for your destination (server). Another reason, why RTC-alarm was used is: I wanted to automatize the whole task. WOL require that I send packages, while RTC-alarm haven’t got any requirement, so less work with less required device 🙂
Check you RTC:
With the following command you can check without reboot / shutdown that your hardware & software configuration supports RTC-alarm function.
Here is the command, how can you check the actual status of your RTC:
Now check ,that our HW & SW configuration supports RTC-alarm function:
As you can see, function is supported:
Create file on “/usr/local/sbin/energy_save.sh” path.
Fill up with the following content (in VI before you start to edit file, push “Insert” button):
Write to file changes (in VI –> “Esc” then “:x”). Dont left to add executable-bit to file.
& now test, that works fine (now you will shutdown your computer after 1 minute then power on it with RTC-alarm function)
If everything is work fine, adjust your script when you server will power on (now after 3 minutes! adjust it to your need, like –>”+ 5 hours”)
As last step for fully automatize add your script to crontab:
add the following line
This script will be run on everyday at 01:00 by crontab.
If not familiar with crontab’s adjustment, here you find a calculator.