← All posts

FreeBSD. Updating the Time Zone at the President's Command

FreeBSD logo

On February 8, 2011, Russian President Dmitry Medvedev instructed the government to abolish clock changes: after switching to daylight saving time on March 27, 2011, Russia was to remain on daylight saving time, which is 1 or 2 hours ahead of standard time (adopted by decree in 1919), depending on the region. In accordance with this instruction, the “Law on the Calculation of Time” was drafted and adopted by the State Duma on May 20. On June 3, 2011, the president signed the law, and it came into force on August 5, 2011. Daylight saving time

FreeBSD 8.1, like plenty of other software, did not comply with Dmitry Anatolyevich’s new law, so let’s fix the situation.

Let’s install zoneinfo; we’ll get the new time zone from there.


$ cd /usr/ports
$ portsnap fetch update
$ cd misc/zoneinfo
$ make install clean

Let’s check whether the time zone we need works, and check the current time:


$ zdump /usr/share/zoneinfo/Europe/Moscow 
/usr/share/zoneinfo/Europe/Moscow  Wed Nov  9 00:16:29 2011 MSK
$ date
Wed Nov  8 23:16:40 MSK 2011

As we can see, there’s a discrepancy, so let’s install the new, correct time zone:


$ cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime 
$ date
Wed Nov  9 00:16:56 MSK 2011

Don’t forget to restart “mysqld”:


/usr/local/etc/rc.d/mysql-server restart

PHP Didn’t Take Off?

If PHP didn’t take off, use pecl-timezonedb:


cd /usr/ports/misc/pecl-timezonedb
make install clean

and make sure that “timezonedb.so” has been added to “/usr/local/etc/php/extensions.ini”:


...
extension=timezonedb.so

Synchronization

Synchronize your time:


ntpdate -v -b europe.pool.ntp.org

You can configure “rc.conf” to keep the time synchronized:


ntpdate_enable="YES"
ntpdate_hosts="europe.pool.ntp.org"

You can also read the ntpdate man page and see what other configuration options are available for “rc.conf”:


$ grep -r ntpdate /etc/defaults/rc.conf 
ntpdate_enable="NO"             # Run ntpdate to sync time on boot (or NO).
ntpdate_program="/usr/sbin/ntpdate"     # path to ntpdate, if you want a different one.
ntpdate_flags="-b"              # Flags to ntpdate (if enabled).
ntpdate_config="/etc/ntp.conf"  # ntpdate(8) configuration file
ntpdate_hosts=""                # Whitespace-separated list of ntpdate(8) servers.

Comments are closed. Read the original discussion in Russian →