How to set time zone on linux VPS (openVZ) in Centos Print

  • 1

we explain in steps

  1. login to your OpenVZ Node.
  2. Stop the container you wish to set the time. Replace xxx with your container ID.

where xxx is your container iD

Like this

root@ ~]# vzctl stop xxx
Stopping container ...
Container was stopped
Container is unmounted

3-Now we to set the capability for the container to change the time zone.
zctl set xxx --capability sys_time:on --save
CT configuration saved to /etc/vz/conf/xxx.conf

where xxx is container ID

4- Go ahead and start the container.
root@ ~]# vzctl start xxx
Starting container...
Container is mounted
Adding IP address(es): x.x.x.x
Setting CPU limit: 400
Setting CPU units: 1000
Setting CPUs: 2
Container start in progress...

5- Login to the container.

[root@ ~]# vzctl enter xxx
entered into CT xxx

6-Check the current time using date command.

[root@/]# date
Sun Apr 19 07:18:29 UTC 2021
and also
Check Current TimeZone.
7 date +'%Z %z'

8-You may change the localtime to (Karachi) as below. This timezone may vary depending upon the time you want to set.

  1. Backup current TimeZone in /root directory
    cp /etc/localtime /root/timezone.old
  2. Create Symbolic Link to your desired TimeZone
    Our desired TimeZone is IST
    ln -sf /usr/share/zoneinfo/Asia/karachi /etc/localtime
  3. Check Date
    date
  4. Verify TimeZone
    date +'%Z %z'
[root@/]# mv /etc/localtime /etc/localtime_bk
[root@svr1 /]# ln -s /usr/share/zoneinfo/Asia/Karachi /etc/localtime

8- again check with command date and confirm time zone
[root@/]# date

you can change the
date and time
date --set="23 June 1988 10:00:00"
date --set="10:00:00"

Was this answer helpful?

« Back

Powered by WHMCompleteSolution