Thursday, December 20, 2012

How Many Squares? The Definitive Answer

This appears on Facebook frequently: How many squares to you see in this picture?

The definitive answer: 40. Here's the proof:

Count 'em: 40 squares.

Saturday, December 15, 2012

Schedules and Power Savings

I recently became aware of just how much of my monthly electric bill is due to having 3 computers running 24/7. (I was using AEP Ohio's online consumption calculator to figure out how much it was going to cost me to keep my Christmas lights on for an extra hour each evening: $0.75 for the month of December.) The natural conclusion is to turn off computers when they're not in use. Well, duh.

But what does it mean for a computer to be "in use"? For me, in addition to the obvious it includes the wee hours of the morning when I have my updates and virus scans scheduled to run. In my ideal world, my computer would behave as shown in this table:

DayTime RangePower SettingRationale
All00:00-06:35Stay onBackups, updates, and virus scans are running
M-F06:35-17:00Hibernate after 10 minutesI'm at work so I don't need to use my computer, but I may want to use it for a few minutes before I dash out the door to work so I don't want it to just shut down; hibernate after 10 minutes is about right
M-F17:00-00:00Sleep after 20 minutesI may or may not be home but I want my computer to sleep when I'm not sitting in front of it
S-S06:35-00:00Sleep after 20 minutesDitto

Being the geek that I am, I started trying to figure out how to set up my computer to automatically follow these rules. Recent versions of Windows have configurable power profiles that let you specify a period of inactivity before the computer hibernates or sleeps (as you choose). Unfortunately, these profiles don't allow you to set a schedule for when a low power mode is permissible and when it's not. You can create a power profile that hibernates the computer after 10 minutes of inactivity, but when you activate that profile the computer will always hibernate after 10 minutes regardless of the day or time of day. This obviously won't work for my updating-in-the-wee-small-hours scenario.

My computer's BIOS has a "power-on-schedule" feature. Surely that ought to be of some use. And recent versions of Windows also allow you to create scheduled tasks that will run whenever you program them to. These features, combined with Windows' powercfg.exe utility, provide the solution. powercfg.exe lets you change to a different power profile from the command line (every computer geek's best friend).

For the 00:00-06:00 time range I just use the "Always On" power profile that Windows provides by default. For the other time ranges I created two new power profiles, one named "WeekDays" and the other named "WeekEnds", and configured them appropriately.

I then created three new scheduled tasks (Control Panel -> Scheduled Tasks). One I named "Always On", the second "WeekDays", and the third "WeekEnds". Here's the WeekDays schedule:

The final piece of the puzzle is configuring the BIOS to start up my computer at 17:00 weekdays. If your computer doesn't have this BIOS feature you could create another scheduled task to run powercfg at 17:00 to switch to the "Always On" power profile. To make this one work, since your computer is likely powered off (hibernating) at 17:00, you would check the "Wake the computer to run this task" checkbox on the Settings tab.

Here's to effortlessly reducing the electric bill!

Update [2012-12-17]: The command shown on the Task tab above won't work on Windows XP. Instead you need to run the powercfg.exe command inside a cmd.exe shell. The proper command text to put into the Run field would be:
C:\WINDOWS\SYSTEM32\cmd.exe /c C:\WINDOWS\SYSTEM32\powercfg.exe /s "WeekDays"