Thursday, December 27, 2012

Fixing the TimeZone in OSX (Mountain Lion)

My timezone got misconfigured at some point and my timestamps have been eight hours off.

I tried setting the timezone as described in articles like this:

http://www.ehow.com/how_4660998_change-zone-mac-os-x.html

And using system commands:


~ $ sudo systemsetup -settimezone  America/New_York
Set TimeZone: America/New_York
~ $ sudo systemsetup -gettimezone
Time Zone: Europe/Brussels



I tried suggestions listed here:
http://www.keiths-place.com/blogs/keith/2007/gmt-timezone-problem-mac-os-x

https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/systemsetup.8.html



But my timezone never changes from Europe/Brussels.


Today, I had to study log files to determine if some scheduled jobs actually ran when they were supposed to.

So, it was time to tackle the timezone misconfiguration.

Symptoms: The time displayed on the top apple menu bar appeared correctly, e.g., 11:47 AM, however any time stamp, run using the system date command, would display 17:47.


~ $ echo `NOW`
20121227-175329   
~ $ sudo cp /usr/share/zoneinfo/Europe/Brussels /usr/share/zoneinfo/Europe/Brussels_ORIG
~ $ sudo cp /usr/share/zoneinfo/America/New_York /usr/share/zoneinfo/Europe/Brussels 
~ $ echo `NOW`
20121227-115421

Here's my NOW alias:

alias NOW='echo "`date +%Y%m%d-%H%M%S`"'


I also had to go to the System Preferences | Date & Time and uncheck "Set date and time automatically" and set the time.  I also unchecked the "Set time zone autotmatically using current location".



~ $ ls -l /etc/localtime
lrwxr-xr-x  1 root  wheel  36 Dec 27 17:39 /etc/localtime -> /usr/share/zoneinfo/America/New_York
~ $ echo `NOW`
20121227-173935
~ $ sudo systemsetup -gettimezone 
Time Zone: Europe/Brussels



~ $ sudo systemsetup -gettimezone 
sudo: timestamp too far in the future: Dec 27 11:54:17 2012

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
Time Zone: Europe/Brussels
~ $ sudo systemsetup -gettimezone 
Time Zone: Europe/Brussels

I not pleased that the system thinks my timezone is Europe/Brussels and that I will have to manually adjust for daylight savings time...


~ $ sudo systemsetup -settimezone  America/New_York
Set TimeZone: America/New_York
~ $ sudo systemsetup -gettimezone
Time Zone: Europe/Brussels



... but at least my system time display (xclock) and timestamps work :-/



Sponsor Ads


2 comments: