How to set / change timezone in Sun Solaris

In our core system, there are 3 Sun Fire V120. Two of them are running Solaris 9 and the remaining system running Solaris 8. The timezone of Solaris 9 are already set to Asia/Jakarta because these were installed by me whereas the Solaris 8 was installed by previous engineer and the timezone was set to GMT.

I want to synchronise this machine to an NTP server but because the timezone was set to GMT, the time we get was not in Jakarta timezone (GMT+7), so this tutorial is written to help you how to change timezone to GMT+7 in Solaris operating system.

Below are the steps I did:

1. Jakarta timezone is set to Asia/Jakarta in the system, so check the zoneinfo for Jakarta must be exist in directory /usr/share/lib/zoneinfo/Asia. If there is not exist you should compile the zone manually. Like what I did, on my system only exist Taipei zone under /usr/share/lib/zoneinfo/Asia directory. To do this, use ‘zic’ (Zone Information Compiler) command.

Go to /usr/share/lib/zoneinfo and do the following command:

bash# zic src/asia

This command compiles the zone info present in the file called “asia” and creates a directory called “/usr/share/lib/zoneinfo/Asia” if not exist and add zone info files if the directory is already exist. You can check that now there should be Jakarta zone under /usr/share/lib/zoneinfo/Asia directory.

2. As root, fire up the following command:

bash# export TZ=Asia/Jakarta

This command will set the timezone to Asia/Jakarta. You now can synchronize the system to ntp server nearest to you.
Since I am in Indonesia, I use id.pool.ntp.org server to synchronize the system.
Do the following command to synch to an NTP server:

bash# ntpdate -b id.pool.ntp.org
27 Jun 08:39:05 ntpdate[540]: step time server 202.152.241.82 offset 1.168523 sec

Check the date now:

bash# date
Sat Jun 27 08:40:18 JAVT 2009

JAVT means Java Time (GMT+7) that Jakarta is located.

3. To activate the timezone at boot time, edit file /etc/TIMEZONE, change the TZ value to ‘Asia/Jakarta’.

4. To schedule synchronizing at specific time, we can set the ntpdate command at cronjob. To do this, edit your crontab file and add the following lines:

#Run ntpdate at 4:40 everyday
40 4 * * * /usr/sbin/ntpdate -b id.pool.ntp.org 1> /dev/null

Hope this tutorial will help you to make your Solaris server synchronized to NTP server.