码迷,mamicode.com
首页 > 系统相关 > 详细

linux下日期时间自动同步设置(rdate,ntpdate两种方法)

时间:2016-04-03 20:37:57      阅读:328      评论:0      收藏:0      [点我收藏+]

标签:linux下日期时间自动同步设置(rdate   ntpdate两种方法)   

linux下同步时间,至少有两种方法:
rdate,ntpdate两种。centos最小化安装默认不安装,先确认已经安装过,否则先安装。
其中rdate本身是用来获取远程时间服务器上时间用的,带上 -s 参数,就可以将获取到的时间应用到本地系统。

NAME
       rdate - get the time via the network
SYNOPSIS
       rdate [-p] [-s] [-u] [-l] [-t sec] [host...]
DESCRIPTION
       rdate  connects  to  an  RFC  868 time server over a TCP/IP network, printing the returned time
       and/or setting the system clock.
OPTIONS
       -p     Print the time returned by the remote machine.

       -s     Set the system time to the returned time.

       -u     Use UDP instead of TCP as the transport.

       -l     Use syslog to output errors (cron.warning) and output (cron.info).

       -t     Set timeout in seconds for every attempt to retreive date.
rdate -s time.nist.gov
ntpdate 本身就是用来同步时间的工具。
示例 :ntpdate ntp.sjtu.edu.cn
NAME
       ntpdate - set the date and time via NTP

       Disclaimer:  The functionality of this program is now available in the ntpd program. See the -q com-
       mand line option in the ntpd - Network Time Protocol (NTP) daemon page. After a suitable  period  of
       mourning, the ntpdate program is to be retired from this distribution

SYNOPSIS
       ntpdate [ -46bBdqsuv ] [ -a key ] [ -e authdelay ] [ -k keyfile ] [ -o version ] [ -p samples ] [ -t
       timeout ] [ -U user_name ] server [ ... ]
DESCRIPTION
[略,具体参看linux man手册]
日期时间服务器
同步时间,就必须有时间服务器。通常情况下,我们完全没必要自己搭建,使用公共的时间服务就可以。
参看 国内常用NTP服务器地址及IP  http://www.douban.com/note/171309770/
其中国家授时中心的似乎不能用,推荐使用上海交大ntp服务 ntp.sjtu.edu.cn 或美国授时中心 time.nist.gov
rdate -s time.nist.gov
ntpdate ntp.sjtu.edu.cn
可以加到crontab里定时执行。

本文出自 “boyhack” 博客,请务必保留此出处http://461205160.blog.51cto.com/274918/1759840

linux下日期时间自动同步设置(rdate,ntpdate两种方法)

标签:linux下日期时间自动同步设置(rdate   ntpdate两种方法)   

原文地址:http://461205160.blog.51cto.com/274918/1759840

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!