Changing time zones on FreeBSD

I recently needed to change the timezone on my FreeBSD servers form the default to GMT. This was required as the servers were to be used for GPS based vehicle tracking system which always send date/time in GMT. After a little bit of searching on Google, I was able to come with the following method. Nothing great, just that this blog post would help me in remembering it later on:

First, copy the GMT time zone file to make it the default timezone of the server. The same can be done for any timezone you wish for.

cp /usr/share/zoneinfo/GMT /etc/localtime

[Updated: For FreeBSD 9+ GMT has been replaced by UTC. The code would change to cp /usr/share/zoneinfo/UTC /etc/localtime

Update your server with teh correct date/time using the ntp command

ntpdate -v -b

Check the server time using date command


Now, to make sure that computer syncs itself everytime it boots, add these two lines to your /etc/rc.conf


[Updated: FreeBSD already comes in with  a ntpd and ntpdate binary. No need to install separate ports for just syncing the time.]