Search for:

Available article translations:

How do I change the system time or timezone in a container?

Article ID: 686, created on Oct 6, 2008, last review on May 23, 2014

  • Virtuozzo
  • Virtuozzo containers for Linux
  • Virtuozzo hypervisor


How do I change the system time or timezone in a container?


You cannot change the system time in a container because all VEs on the Hardware Node have the same system time. However, it is possible to change the default system timezone inside a VE, for example, by replacing /etc/localtime with the file from /usr/share/zoneinfo, which contains the description of your timezone.

If it is required to have different time on the node and inside the containers, it will be required to tweak the OS template.

E.g. using centos-6-x86_64 OS template:

  1. Find the occurrence of "/etc/localtime" in any of the scripts of the OS template:

    [root@pcs ~]# grep localtime /vz/template/centos/6/x86_64/config/os/default/*
    /vz/template/centos/6/x86_64/config/os/default/post-cache:[ -f /etc/localtime ] && cp -fp /etc/localtime etc/localtime
  2. Comment such lines, if found:

    [root@pcs ~]# vi /vz/template/centos/6/x86_64/config/os/default/post-cache
    [root@pcs ~]# grep localtime /vz/template/centos/6/x86_64/config/os/default/post-cache
    #[ -f /etc/localtime ] && cp -fp /etc/localtime etc/localtime
  3. Add the following lines to the post-install script:

    [root@pcs ~]# vi /vz/template/centos/6/x86_64/config/os/default/post-install
    [root@pcs ~]# tail /vz/template/centos/6/x86_64/config/os/default/post-install
    # Force regeneration of mime-database, due to shared-mime-info
    # post-install script failure
    /usr/bin/update-mime-database /usr/share/mime > /dev/null 2>&1
    ## Move to a new time zone     <---------added
    rm -f /etc/localtime     <---------added
    ln -s /usr/share/zoneinfo/posix/Asia/Tokyo /etc/localtime     <---------added
    popd > /dev/null
  4. Recreate the OS template cache:

    [root@pcs ~]# vzpkg remove cache centos-6-x86_64 ; vzpkg create cache centos-6-x86_64

Once this is done, any new container, created on this OS template, will get the configured timezone. For existing containers, it's necessary to run the commands manually:

  # rm -f /etc/localtime
  # ln -s /usr/share/zoneinfo/posix/Asia/Tokyo /etc/localtime

Search words:

VPS timezone


date: cannot set date: Operation not permitted

change time

change timezone

e8e50b42231236b82df27684e7ec0beb d02f9caf3e11b191a38179103495106f 2897d76d56d2010f4e3a28f864d69223 a26b38f94253cdfbf1028d72cf3a498b 0dd5b9380c7d4884d77587f3eb0fa8ef

Was this article helpful?
Tell us how we may improve it.
Yes No
Server Virtualization
- Odin Cloud Server
- Odin Containers for Windows 6.0
- Odin Virtuozzo Containers
- Odin Automation
- Odin Automation for Cloud Infrastructure
- Odin Business Automation Standard
- Odin Virtual Automation
- Odin Plesk Panel Suite
- Web Presence Builder
- Odin Plesk Automation
- Odin Small Business Panel
- Value-added Services for Hosters
- Odin Partner Storefront
Services & Resources
- Cloud Acceleration Services
- Professional Services
- Support Services
- Training & Certification