LINUX & 技术 12 Jun 2008 10:57 am
Linux的时间设置与同步 (NTP)
http://x.86516.com/index.php/uid-69-action-viewspace-itemid-4537
http://www.pool.ntp.org是NTP的官方网站,在这上面我们可以找到离我们城市最近的NTP Server. NTP建议我们为了保障时间的准确性,最少找两个个NTP Server
asia的服务器地址
http://support.ntp.org/bin/view/Servers/NTPPoolServers
第二步要做的就是在打开NTP服务器之前先和这些服务器做一个同步,使得我们机器的时间尽量接近标准时间. 这里我们可以用ntpdate命令
代码:
# ntpdate 0.uk.pool.ntp.org
6 Jul 01:21:49 ntpdate[4528]: step time server 213.222.193.35 offset -38908.575181 sec # ntpdate 0.pool.ntp.org 6 Jul 01:21:56 ntpdate[4530]: adjust time server 213.222.193.35 offset -0.000065 sec
现在我们就来创建NTP的配置文件了, 它就是/etc/ntp.conf. 我们只需要加入上面的NTP Server和一个driftfile就可以了
代码:
# vi /etc/ntp.conf
server 0.uk.pool.ntp.org
server 1.uk.pool.ntp.org
driftfile /var/lib/ntp/ntp.drift
非常的简单. 接下来我们就启动NTP Server,并且设置其在开机后自动运行
代码:
# /etc/init.d/ntpd/start # chkconfig –level 35 ntpd on
http://www.ntp.org/downloads.html
Guide to install NTP for Unix/Linux
- gzip -d ntp-4.1.72.tar.gz
- tar -xvf ntp-4.1.72.tar
- cd ntp-4.1.72
- ./configure
- make
- make check
- make install
修改 Linux 系统时区
1. 查看当前时区
# vi /etc/sysconfig/clock
2. 修改设置时区
方法(1) # tzselect 方法(2 仅限于RedHat Linux 和 CentOS) # timeconfig
3. 复制相应的时区文件,替换系统默认时区
# cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime 对于中国服务器则执行: # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
4. 将当前时间写入BIOS永久生效(避免重启后失效)
# hwclock
参考:http://kb.discuz.net/index.php?title=%E4%BF%AE%E6%94%B9_Linux_%E7%B3%BB%E7%BB%9F%E6%97%B6%E5%8C%BA