解决系统时间与硬件时钟错误

错误代码:

       #date        ###查看系统日期显示日期是前几天

解决方法:

       与时间服务器进行时间同步

       #ntpdate time.nist.gov     

       设置时区为东八区

       #rm -rf /etc/localtime
       #ln -s /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime

       将硬件时间同步为系统时间

       #hwclock --systohc

       vim /etc/sysconfig/clock 文件里可以看到时区设置和是否启用时区转换的选项

PS:

      当Linux启动时,系统时钟会去读取硬件时钟的设定,之后系统时钟即独立运作。

      hwclock命令:

                       -r, --show         读取并打印硬件时钟(read hardware clock and print result )
                      -s, --hctosys      将硬件时钟同步到系统时钟(set the system time from the hardware clock )
                      -w, --systohc     将系统时钟同步到硬件时钟(set the hardware clock to the current system time )

       

       

你可能感兴趣的:(解决系统时间与硬件时钟错误)