TUAW Tip: Setting your clock automatically after using Boot Camp
I use Boot Camp pretty regularly, and one thing that always annoyed me about booting back into the world of the living the Mac was that my clock was always eight hours behind (I live in the Pacific time zone). Windows likes to set the system clock to my local time of GMT –8. Mac OS X, on the other hand, likes to keep the hardware clock at GMT, and set it "softly" using the operating system software. There are some hairy registry fixes for the Windows behavior, but they're unsupported.
While manually setting my clock back for the eleventy billionth time, I noticed that just opening and closing the Date & Time preference pane sets the clock automatically. Of course, I had to be connected to the Internet, and have the "set date & time automatically" checkbox selected.
Sensing an opportunity to make my life easier, I wrote myself an AppleScript that simply opens the Date & Time preference pane, leaves it open for a few seconds, and then closes it. I saved it as an application, and set it to run at startup.
That way, by the time my computer is finished booting, the clock is right, and I didn't have to even think about it.
After the jump, some code and instructions on how to do this yourself.
Here's how you can create a helper app like this to set your clock automatically every time your computer boots.
- From the Apple menu, choose System Preferences.
- Click Date & Time.
- Make sure the Set date & time automatically box is checked.
- Start Script Editor (which is usually located in the AppleScript folder in your Applications folder).
- From the File menu, choose New.
- Type or paste the following code:
tell application "System Preferences"
reveal pane "Date & Time"
end tell
delay 5
quit - Click Compile in the toolbar to make sure there are no problems with your code.
- You can try it out live by clicking Run, too.
- Back in Script Editor, choose Save As ... from the File menu.
- Enter a name like Set Clock Automatically.
- Choose a location to save the app. (I put mine in the Utilities folder inside my Applications folder.)
- From the File Format drop-down, select Application.
- Click Save.
- You can quit Script Editor, if you want.
- From the Apple menu, choose System Preferences.
- Click Show All, then click Accounts.
- In the left pane, click the name that corresponds to your user account.
- Click the Login Items tab.
- Click the + button below the list of applications.
- Find and select the application you saved in steps 6-10.
- Click Add.
- You can quit System Preferences, if you want.
As a wise author once said, "do these steps, and then you're done." Make sure you're connected to the Internet, and then give it a try by restarting into Windows, and restarting back into Mac OS X.
I've been using this script with Mac OS X 10.4 "Tiger" and 10.5 "Leopard," and have had no problems.
Share
Categories
I use Boot Camp pretty regularly, and one thing that always annoyed me about booting back into the world of the living the Mac was that my...
Add a Comment
Are you using the latest version of Boot Camp?
I used to have this problem, but when I recently set-up a new Boot Camp drive and got the latest version of the Windows drivers (2.1 I believe), the problem didn't exist anymore.
It seems that if you have your software up to date, Apple has already fixed the problem.
Are you talking about my keyboard problem or the clock problem? I have got the latest 2.1 and still have a problem with the keyboard. It accepts my passkey but next time I boot into Windows it says no Passkey and connected but it still won't work till I turn it off and on again.
June 06 2008 at 2:34 AM Report abuse Permalink rate up rate down ReplyThere is a much more elegant way to make sure your OSX and Windows time are always in sync. The only complete solution to this problem should not require any time sync from a server at all. The problem seen here is due to the fact that OSX expects the computer's hardware clock to be set to UTC where Windows expects it to be set to local time.
The way to fix this is to tell Windows that the time stored in the hardware is UTC, just like in OSX. This is done with a single registry entry:
HKLMSYSTEMCurrentControlSetControlTimeZoneInformationRealTimeIsUniversal
Set this key to a DWORD value of 1, then reboot.
This will cause Windows to handle the hardware time the same as OSX, meaning that it doesn't matter which OS requests a time sync since they will always match.
I've used this method on a Mac Pro and a MacBook Pro using OSX 10.4 and Windows XP. I've not tried it with 10.5 because I haven't been using bootcamp for a while and I never tried it with Vista because I hate it.
The problem here is with the Mac OS X Not Windows. The Mac OS X uses ntpd to sync time with network servers. (ntpd is free open source software that when configured properly is MUCH better then the time sync software that Windows uses). Almost all Linux distros configure ntpd properly. But Apple Mac OS X does not.
I suspect Apple has intentionally configured ntpd poorly to reduce the load on the Apple time servers.
e.g. Open up Terminal and type:
ntpq -p
If you see a * beside a time server (e.g. time.apple.com), your Mac's clock is synced with that time server. But I suspect many of you will not see a * but that can be fixed!
Here is an easy solution. In terminal from an Administrators Account, do the following:
1. sudo nano /etc/ntp.conf
2. In the nano editor, change the line starting with server to:
server time.apple.com iburst
3. Save the file. Ctrl-X in nano.
4. Reboot.
For more info and a more complicated procedure on Tiger, see the Apple website:
http://docs.info.apple.com/article.html?artnum=303731
Please note you don't have to use the Apple time servers. For a list of time servers, see http://support.ntp.org/bin/view/Servers/WebHome
Pick one that is closest to you. (you can tell by pinging the time server in Terminal. e.g. ping time.nrc.ca to ping the official Canadian time server in Ottawa). The time.apple.com is often not ideal for syncing time but it depends where you live.
Please note that one thing that Apple does NOT tell you is if you unlock and then lock the Time and Date System Preferenes, Mac OS X will overwrite the ntpd setttings with the poor ones.
To check if everything is working properly, open up Terminal and type:
ntpq -p
You should see a * beside a time server which tells you that your Mac's clock is synced with that time server.
How silly! Just disable all automatic time-adjustment features of Windows (daylight saving and network time) and you're done. Way easier.
June 04 2008 at 6:29 AM Report abuse Permalink rate up rate down Replyi never noticed that bug! the joys of living in GMT
June 04 2008 at 4:07 AM Report abuse Permalink rate up rate down ReplyIt seems you lot have trouble with this,
I myself use Bootcamp, WXP and Leopard 10.5.3 almost daily and never have trouble with the time. I have both OS'es set to GMT+1 and on both auto updating the time with time.euro.apple.com is set (yes on windows too!)
sigh.
i hate it when 'gurus' attempt to 'fix' a problem and end up making an unholy, godawful mess of it, like here.
seriously, did you put any effort into researching timekeeping in Mac OS X before writing the script and this article?
as a previous poster says, it's a one-liner. An alternative is to edit the ntpd config file since the ntpd runs in the background permanently anyway, and as stated, does not perform an update if the error margin is too high.
a one-liner. that is run once. then forget about it.
compare that to "open sys prefs every time your computer boots. wait a minute. close it." even if it's scripted - that's not a solution. that's not even a hack. that's just retarded.
There's actually the Mother of All Bugs in OS X since nearly the 10.1 It's complicated but certain prefs after a disgraceful reboot or something like bootcamp will be lost.
On notebooks it's ambient brightness, and automatic time. Drives ME INSANE, does it on all 50+ notebooks I've owned, and I can reproduce it on anybody's mac notebook.
Well, I used one of those 'hairy' registry fixes without any problems :-)
Easier, especially when I'm not connected to teh interwebz.
An even easier solution is to get the network time protocol daemon to do the work for you. It doesn't do it now as it doesn't like resetting your time if it is out by a large margin but you can tell it to ignore the margin.
Open the Terminal and, if you have admin rights, this line fixes it :-
sudo printf "nntpd -g -qn" >> /etc/rc.local
which adds a line to one of the shell scripts run at boot (the first, in fact, which doesn't exist by default) and whenever you boot your Mac the time server will be checked and your time fixed.
The advantage of this fix is that if you have Active Directory logins the time will be fixed before the Login Window comes up and a bad time can upset AD.
# Tony Williams
http://honestpuck.blogspot.com/
Hot Apps on TUAW
Deals of the Day
more deals- Altec Lansing Octiv Duo iDock for $48 + free shipping
- Used Apple iMac 17" Core Duo 1.83GHz for $430 + $28 s&h
- Lounge Deluxe Stand for iPhone / iPod touch for $28 + $8 s&h
- Brookstone Surround-Sound Earbuds for $14 + $7 s&h
- Refurbished Skullcandy Tokidoki Smokin' Buds Mic'd Headset for $5 + $2 s&h
- Stitchway Backup Battery for iPod / iPhone for $5 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



26 Comments