User Tools

Site Tools


deli:configuration:timezone

Setting your local time zone and performing synchronization with an NTP server

DeLi Linux uses uClibc which relys on the TZ variable to specify the local time zone parameters, unlike other implementations which refer to zoneinfo. While you can simply set the hardware clock to local time it is recommended that it be set to UTC and the TZ variable used to set the offset for the local time zone.

1. The TZ variable

The TZ variable needs to be set according to The Open Group Base Specifications. In addition, the /etc/TZ file also needs to have the same value. The TZ value requires a specific format specifying the time zone offset and Daylight Saving Time offset and effective dates (if observed). This can be difficult to figure out but the OpenWrt project also uses uClibc and their configuration page lists examples for many time zones. For example, US Eastern Standard time is “EST5EDT” to indicate a UTC-5 offset with DST (-4) occuring at the default dates(?) and time of 02:00:00 (2:00am). The /etc/TZ file value requires a newline at the end of the value else it may not be read correctly. To set the TZ variable (to US Eastern Standard Time) at boot, add the following to the end of /etc/profile:

export TZ='EST5EDT'

2. Synchronizing time to an NTP server

DeLi includes msntp which can act as a client or server and be installed as a service. For basic client operation the command is:

msntp <NTP server> 

This shows the current time difference between system time and UTC. For most users, the NTP pool servers are accurate enough and help distribute the load among NTP servers. To set the time using the pool enter:

msntp -a pool.ntp.org

If that doesn't work, try:

msntp -r pool.ntp.org

If the difference is large it will prompt you to confirm. The sanity checks and other features can all be modified - see the man page (“man msntp”). To set the time at boot, edit /etc/rc.local and add the command:

#
# /etc/rc.local: local multi-user startup script
#

# Set system time from public time servers
/usr/sbin/msntp -a pool.ntp.org

# End of file

Obviously, if your Internet connection is dial-up modem then you probably want to run it manually instead.

deli/configuration/timezone.txt · Last modified: 2010/09/02 15:06 (external edit)