/usr/share /zoneinfo/Asia/Shanghai" command to change the time zone to Shanghai."/> /usr/share /zoneinfo/Asia/Shanghai" command to change the time zone to Shanghai.">
Home >Operation and Maintenance >Linux Operation and Maintenance >Why does the Linux system time keep changing?
Solutions to the Linux system time always changing: 1. Check the system time zone link file through "/etc/localtime"; 2. By executing "lrwxrwxrwx. 1 root root 33 Mar 29 16:55 /etc/localtime -> /usr/share/zoneinfo/Asia/Shanghai" command to change the time zone to Shanghai.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
Why does the Linux system time always change?The Linux server time is always wrong?
Some people are curious that their server time has been changed correctly, but after a while, the system time becomes wrong again.
The way people modify the time is generally to use the date command to modify the time, or to use the ntp command to synchronize the time
In this case, if your server is not a physical machine, but a virtual machine , it is not a problem with the hardware time hwclock, but that the default time zone was used or the wrong time zone was selected when installing the system.
Check your system time zone link file: (Obviously New York is selected as the time zone here)
[root@localhost ~]# ll /etc/localtime lrwxrwxrwx. 1 root root 38 May 31 2018 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
Modification: (Change the time zone to Shanghai)
[root@localhost ~]# rm /etc/localtime rm: remove symbolic link ‘/etc/localtime’? y [root@localhost ~]# ll /etc/localtime ls: cannot access /etc/localtime: No such file or directory [root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@localhost ~]# ll /etc/localtime lrwxrwxrwx. 1 root root 33 Mar 29 16:55 /etc/localtime -> /usr/share/zoneinfo/Asia/Shanghai
Use the date command to check whether the time has been restored. If not, use the ntp command to synchronize the time, and the time will not be wrong later.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of Why does the Linux system time keep changing?. For more information, please follow other related articles on the PHP Chinese website!