1、查询系统时间
root@localhost ~]
Wed May 31 10:12:43 EDT 2017
2、设置系统时间
[root@localhost ~]
Wed May 31 14:12:30 EDT 2017
3、查看硬件时间
[root@localhost ~]
Wed 31 May 2017 02:13:27 PM EDT -0.318870 seconds
4、设置硬件时间
[root@localhost ~]
5、时间同步
按照前面的说法,重新启动系统,硬件时间会读取系统时间,实现同步,
但是在不重新启动的时候,需要用hwclock或clock命令实现同步。
硬件时钟与系统时钟同步:
1)、硬件时间同步到系统时间
[root@localhost ~]
2)、系统时间同步到硬件时间
[root@localhost ~]
3)、和外部的NTP时间服务器同步
1)
[root@localhost ~]
这一步是必须的,否则出出现:
25 Nov 18:10:34 ntpdate[2106]: the NTP socket is in use, exiting 的失败提示;
[root@localhost ~]
正常返回如下:
25 Nov 18:14:34 ntpdate[2164]: adjust time server 202.120.2.101 offset -0.006107 sec
错误返回如:
25 Nov 18:13:44 ntpdate[2158]: no server suitable for synchronization found
[root@localhost ~]
[root@localhost ~]
[root@localhost ~]
2)写进定时任务中,以做定时的时钟同步:
[root@localhost ~]
05 * * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn >> /dev/null 2>>&1
05 17 * * * /sbin/clock -w