Linux system time zone settings

When starting to set the time zone, refer to the information on the Internet and use the tzselect command. It turns out that the tzselect command only tells the method of setting the time zone, rather than actually modifying the file /etc/sysconfig/clock. In other words, the tzselect command just tells us the time zone selected by setting the TZ environment variable, and then adding the variable to the .profile file. The following briefly introduces how to use the tzselect command to set the time zone, and how to set the time zone by modifying the /etc/sysconfig/clock configuration file.

tzselect:

Execute the tzselect command --> select Asia--> select China--> select east China - Beijing, Guangdong, Shanghai, etc--> then enter 1. The process is as follows:

After executing the tzselect command to select the time zone, the time zone has not changed, but at the end of the command you are prompted that you can execute TZ='Asia/Shanghai'; export TZ and add this line to .profile, then log out and log in again. Referring to the result seen by the date command in the figure below, the final time zone is displayed as CST, which is China Standard Time.

Modify the configuration file to modify the time zone

1、修改/etc/sysconfig/clock         ZONE=Asia/Shanghai

2. rm /etc/localtime3, link to the Shanghai time zone file       

 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

After performing the above process, restart the machine and you can see that the time zone has been changed.

 

This article is reproduced from: https://jingyan.baidu.com/article/fa4125acb7328628ac70920e.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325247476&siteId=291194637