Article ID: 123371, created on Nov 1, 2014, last review on Nov 1, 2014

  • Applies to:
  • Virtuozzo
  • Virtuozzo containers for Linux
  • Virtuozzo hypervisor


Time was not adjusted automatically in container after updating tzdata package in a CentOS/Redhat container.


Time was not adjusted because /etc/localtime file was not updated. And /etc/localtime was not updated because /etc/sysconfig/clock file is missing - it should contain timezone which is used on a server for system to update /etc/localtime automatically

This issue was confirmed as a bug with internal ID #PSBM-29853


To fix the issue for existing containers it's necessary to copy /etc/sysconfig/clock from hardware node:

[root@pcs ~]# cp -fp /etc/sysconfig/clock /vz/root/<CTID>/etc/sysconfig/clock

NOTE: <CTID> should be replaced with Container ID in question.

Once it's copied, reinstall tzdata package in the container:

[root@container ~]# yum reinstall tzdata -y

Permanent fix should be applied to the OS template post-cache script. Add following line to /vz/template/<OS>/<RELEASE>/<ARCH>/config/os/default/post-cache file:

[ -f /etc/sysconfig/clock ] && cp -fp /etc/sysconfig/clock etc/sysconfig/clock
  • <OS> should be replaced with OS in question (e.g. centos, redhat,...)
  • <RELEASE> should be replaced with release in question (e.g. 5, 6,...)
  • <ARCH> should be replaced with arch in question (e.g. x86 or x86_64)

Make sure to add line next to the line that copies "localtime" file. E.g.:

# diff -pruN post-cache.original post-cache
--- post-cache.original 2014-11-01 15:57:23.294445979 +0600
+++ post-cache  2014-11-01 15:58:00.181968471 +0600
@@ -23,6 +23,7 @@ fi
pushd $rootdir > /dev/null

 [ -f /etc/localtime ] && cp -fp /etc/localtime etc/localtime
+[ -f /etc/sysconfig/clock ] && cp -fp /etc/sysconfig/clock etc/sysconfig/clock
 [ -f /etc/sysconfig/i18n ] && cp -fp /etc/sysconfig/i18n etc/sysconfig/i18n

 popd > /dev/null

Once you've added the line it will be necessary to update template cache:

# vzpkg update cache <TEMPLATE_NAME>

Search Words

localtime not updated

Time zone not updated in containers

a26b38f94253cdfbf1028d72cf3a498b 2897d76d56d2010f4e3a28f864d69223 d02f9caf3e11b191a38179103495106f e8e50b42231236b82df27684e7ec0beb 0dd5b9380c7d4884d77587f3eb0fa8ef

Email subscription for changes to this article
Save as PDF