linux服务器版如何更新系统时间,如何更新linux服务器的系统时间

由于服务器的时间出现错误,可采用以下方法来更新linux服务器的系统时间:

方法一:

1,首先yum 安装本地ntpdate客户端,更新ntpdate cn.pool.ntp.org时使用

[root@localhost ~]# yum install ntpdate

2,使用ntpdate cn.pool.ntp.org进行更新。

[root@localhost ~]# ntpdate cn.pool.ntp.org

15 Sep 16:46:32 ntpdate[15965]: adjust time server 202.112.29.82 offset 0.010499 sec

或者使用cn.pool.ntp.org 的ip地址进行更新。

[root@localhost ~]# ping cn.pool.ntp.org

PING cn.pool.ntp.org (202.112.10.36) 56(84) bytes of data.

64 bytes from gus.buptnet.edu.cn (202.112.10.36): icmp_seq=1 ttl=44 time=107 ms

64 bytes from gus.buptnet.edu.cn (202.112.10.36): icmp_seq=2 ttl=44 time=86.2 ms

ntpdate

[root@localhost ~]# ping cn.pool.ntp.org

PING cn.pool.ntp.org (202.112.10.36) 56(84) bytes of data.

64 bytes from gus.buptnet.edu.cn (202.112.10.36): icmp_seq=1 ttl=44 time=107 ms

64 bytes from gus.buptnet.edu.cn (202.112.10.36): icmp_seq=2 ttl=44 time=86.2 ms

[root@localhost ~]# ntpdate 202.112.10.36

15 Sep 16:49:14 ntpdate[15966]: adjust time server 202.112.10.36 offset 0.010657 sec

3,更新完后要用 clock -w 或 hwclock -w 实时间写入到BIOS中,这样下次启动时,时间就会自动更新了。

[root@localhost ~]# clock -w

方法二:

直接使用命令进行更新,ntpdate time-a.nist.gov

[root@localhost ~]#  ntpdate time-a.nist.gov

备注:常用的命令:

date           #显示当前时间,这个是系统时间

clock          #显示硬件时间

hwclock        #硬件时间

hwclock -w     #将系统时钟写到硬件时钟

hwclock -s     #将硬件时钟写到系统时钟

互联网常用的ntp时间同步站点:

time-a.nist.gov

time.windows.com

time.nist.gov