Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Modify the UTC in the direct console of the ESXi host to CST

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Note: the author's environment is ESXi 6.7,

Sometimes we will see that the time in the ESXi host is different from our actual Beijing time. As shown in figure 1-1 below, it shows the UTC time, UTC,Universal Time Coordinated, also known as the zero time zone, which differs by 8 time zones from the Beijing time zone in China. CST can be regarded as the standard time of the United States, Australia, Cuba or China. China's time zone is the East eighth Zone, using the CST time zone, eight hours ahead of UTC.

Sometimes we need to change this time to the well-known East eighth Zone. Through this article, we modify the time zone of the ESXi direct console. This article is only applicable to modify the time zone and take effect in the ESXi direct console, and will not have any effect on the time zone displayed by vSphere Host Client.

Figure 1-1 UTC time on the ESXi host

In ESXi systems, the date-time-related file is / etc/localtime, while in mainstream Linux systems, date-time-related files are also / etc/localtime. There is no problem of UTC time in Linux system, so we can borrow the localtime file in Linux system to replace the localtime file in ESXi system. Let's start the localtime file substitution process.

Log in to a Red Hat Enterprise Linux through WinSCP file transfer software, and then download the / etc/localtime file to a USB drive.

Log in to the ESXi host system through the WinSCP file transfer software, first back up the original / etc/localtime file in the ESXi host, and the backup name can be changed to localtime.back. Where to back up, according to your own situation, you can back up to your own U disk so that you can restore it back in case of problems in the future.

After backing up the original localtime files, upload the localtime files downloaded from the Linux server to the data storage directory of the ESXi host, other directories ESXI restart the system will restore, and the files will be lost. The data storage directory in our current environment is / vmfs/volumes/sdisk, while sdisk is a color-linked file that points to / vmfs/volumes/5dd64ab1-ad655a44-2477-000c2978d123, as shown in figure 1-2 below.

Figure 1-2 stores the link directory

As shown in figure 1-3 below, localtime already exists in the data storage directory, but the work is not completed. The purpose of storing localtime in the data storage directory is only to prevent the loss of ESXi machine reboot. Eventually we have to put this file in the / etc directory to take effect, so we also need to copy it to the / etc/ directory of the ESXi host.

Figure 1-3 upload localtime file to data storage directory

We open the Shell function under the ESXi direct console, press the Alt+F1 shortcut key to enter the command line interface, and then use the copy command to overwrite the localtime file under / etc, cp-if / vmfs/volumes/sdisk/localtime / etc/localtime. When prompted whether to overwrite the localtime under / etc/, we select "y", as shown in figure 1-4 below.

Figure 1-4 overwrites the original localtime file

In order to prevent the / etc/localtime file from returning to its original form after the ESXi host is rebooted, we can write the copy command into the automatic startup script file / etc/rc.local.d/local.sh, execute the command vi / etc/rc.local.d/local.sh in the ESXi direct console command line interface, open the local.sh executable file, add the command line and save and exit, as shown in the following figure.

Figure 1-5 copy the localtime file to the / etc/ directory

Later in the process, regardless of whether the ESXi host is rebooted or not, when we check the date and time with the data command, it shows the CST time. This is shown in figure 1-6 below.

Figure 1-6 shows the CST time

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report