10.6: Turn off automatic wake-from-sleep network check

Apr 02, '10 07:30:00AM

Contributed by: fds

Snow Leopard only hintOne of Snow Leopard's advertised new features is the much more ambitious 'wake for network access' functionality. What was previously a setting only used by geeks and network administrators -- people who readily knew what a 'magic packet' was and how to send one -- has now been expanded and simplified to make it into a feature any user could understand and make use of. A lot of work went into making it just work in any environment.

Unfortunately for those of us who were already happy with the wake on Ethernet access feature as it was in Leopard and before, they fixed what, in our case, didn't need fixing. In Snow Leopard, if you enable waking for network access, your Mac will periodically wake up every two hours (possibly sooner), no matter what. Mind you, it's a special new 'lightweight wake' with the display staying off, and it'll go right back to sleep in about 20 seconds. Still, I absolutely hated the periodic hard drive and fan noise, the apparent pointlessness and wastefulness of it all.

A comment in mDNSResponder's open source code offers some explanation:

we still want to wake up in at most 120 minutes, to see if the network environment has changed. E.g. we might wake up and find no wireless network because the base station got rebooted just at that moment, and if that happens we don't want to just give up and go back to sleep and never try again.
In my case, the network environment is static and only I could change it. I don't use wireless wake, Back to My Mac, or AirPort Extreme's sleep proxy. So how do I turn off this auto-wake feature then?

The code in mDNSResponder makes only two checks on when not to schedule the maintenance wakes:

This check is always made at the point the machine is about to go to sleep. After much experimentation, I finally have a reliable way of defeating this check without really doing either of the above.

Using sleepwatcher, add the following commands to your script to run when your computer is going to sleep:
/bin/sleep 1
/usr/sbin/systemsetup -setwakeonnetworkaccess on >/dev/null
And add this to your 'wakeup' script:
/usr/sbin/systemsetup -setwakeonnetworkaccess off >/dev/null
Finally, also execute that last command right now, or just manually turn 'Wake for network access' off in the Energy Saver preferences.

What this does is turn wake for network access on only at the very last moment when your machine is going to sleep. This way, mDNSResponder will be fooled into thinking you don't have network wakes enabled, so it won't schedule the unwanted maintenance wake. In reality, though, your sleep script will enable it anyway, but in such a way that mDNSResponder doesn't see it.

Comments (6)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100401103451497