2015-10-26
//查看可用ntp的rpm包 [root@mdb ~]# rpm -qa|grep ntp fontpackages-filesystem-1.41-1.1.el6.noarch ntp-4.2.6p5-3.el6.centos.x86_64 ntpdate-4.2.6p5-3.el6.centos.x86_64 //查看是否安装了ntp [root@mdb ~]# yum list|grep ntp fontpackages-filesystem.noarch 1.41-1.1.el6 @anaconda-CentOS-201303020151.x86_64/6.4 ntp.x86_64 4.2.6p5-3.el6.centos @updates ntpdate.x86_64 4.2.6p5-3.el6.centos @updates //查看ntpd服务状态 [root@mdb ~]# service ntpd status ntpd dead but pid file exists //重启ntpd服务 [root@mdb ~]# service ntpd restart Shutting down ntpd: [FAILED] Starting ntpd: [ OK ] //再次查看ntpd服务状态 [root@mdb ~]# service ntpd status ntpd (pid 31909) is running... //查看曾经同步过的时间服务器 [root@mdb ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== 202.118.1.130 202.118.1.46 2 u 4 64 3 74.113 6512611 2.349 news.neu.edu.cn 202.118.1.46 2 u 3 64 3 45.810 6512613 8.422 dns1.synet.edu. 202.118.1.46 2 u 2 64 3 137.909 6512615 1.870 dns2.synet.edu. .INIT. 16 u - 64 0 0.000 0.000 0.000 //查看当前时间 [root@mdb ~]# date Sun Oct 25 16:19:42 CST 2015 //同步时间 [root@mdb ~]# ntpdate 202.118.1.130 26 Oct 10:27:48 ntpdate[32157]: the NTP socket is in use, exiting //查看同步后的时间 [root@mdb ~]# date Mon Oct 26 10:27:52 CST 2015 //同步时间计划任务 [root@mdb ~]# crontab -e # system time sync leocen@2015-10-29 0 */4 * * * /usr/sbin/ntpdate 202.118.1.130 >/dev/null 2>&1; /usr/sbin/hwclock -w >/dev/null 2>&1