Modify Linux time zone, synchronize time

Time zone setting:
        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, but does not really modify the /etc/sysconfig/clock file. 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

After executing the tzselect command to select the time zone, the time zone does not change, just in The command finally prompts you to execute TZ='Asia/Shanghai'; export TZ and add this line to .profile, then log out and log in again. Referring to the results of the date command in the following figure, the final time zone is displayed as CST, which is China Standard Time.

Modify the configuration file to modify the time zone

1, modify /etc/sysconfig/clock ZONE=Asia/Shanghai

2, rm /etc/localtime

3, Link to the Shanghai time zone file      

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

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326691738&siteId=291194637