现在的位置: 首页 > 综合 > 正文

linux 时间自动同步

2014年08月09日 ⁄ 综合 ⁄ 共 758字 ⁄ 字号 评论关闭

1、调整时区
    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

linux提供是依据/etc/localtime文件内容知道目前系统的时区信息,这个文件一般是从/usr/share/zone/里面选择适当的时区复制过来就可以使用

2、手动调整时间(需要ntpdate)
    ntpdate us.pool.ntp.org
没有安装ntpdate可以
    yum install -y ntpdate

3、加入定时计划任务,每天进行同步一次:
   /etc/cron.daily 目录中建立一个脚本ntpupdate,內容如下表所示:

#! /bin/bash

/usr/sbin/ntpdate -s us.pool.ntp.org

/usr/sbin/hwclock --systohc

另用下列指令设定脚本可执行:

# chmod +x /etc/cron.daily/ntpupdate

<!--EndFragment-->
中国国家授时中心:

http://www.time.ac.cn/stime.asp

其他网络时间服务器地址如下
time.nist.gov(美国)
ntp.fudan.edu.cn(复旦)(国内用户推荐使用此服务器)
timekeeper.isi.edu
subitaneous.cpsc.ucalgary.ca
usno.pa-x.dec.com
time.twc.weather.com
swisstime.ethz.ch
ntp0.fau.de
ntp3.fau.de
time-a.nist.gov
time-b.nist.gov
time-nw.nist.gov
nist1-sj.glassey.com

抱歉!评论已关闭.