---
title: "Linux时间服务器及客户端同步配置-SUSE11"
author: "mini_hu"
date: "2011-01-01T21:41:09Z"
tags: []
categories: ["操作系统"]
slug: "linux-suse11"
draft: false
lastmod: "2011-01-01T21:41:09Z"
id: 857465
url: "https://pwind.iteye.com/blog/857465"
---

一、时区设置
使用utc还是local time. 
UTC(Universal Time Coordinated)=GMT(Greenwich Mean Time) 
Local time 是你手表上的时间
linux可以处理UTC时间和蹩脚的Windows所使用的local time 
如果机器上同时安装有Linux和Windows，建议使用local time 
如果机器上只安装有Linux，建议使用utc 
确定后编辑/etc/sysconfig/clock, UTC=0 是local time; UTC=1 是UTC(GMT)

1）/etc/sysconfig/clock查看当前时区
HWCLOCK="-u"	#与下面设置的时区对应
下面2项不用改#jvm/Nginx等程序取的时间才与date命令时间一致
TIMEZONE="America/New_York"
DEFAULT_TIMEZONE="US/Eastern"

2）使用tzselect设置时区（========好像对时间同步没有用）
#/usr/bin/tzselect
逐步选择就ok

3）复制相应的时区文件，替换系统默认时区 
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
或者 cp /usr/share/zoneinfo/Asia/Beijing /etc/localtime（====这个不能同步时间，不知原因）

4）java时区：java_opts增加 -Duser.timezone=GMT+8

二、时间同步
内网时间服务器：172.22.14.11
1）服务器端配置/etc/ntp.conf
restrict 127.0.0.1
restrict 172.22.12.0 mask 255.255.255.0 #有几种都配置上
restrict 172.22.13.0 mask 255.255.255.0
restrict 172.22.14.0 mask 255.255.255.0
restrict 172.22.15.0 mask 255.255.255.0

server 218.75.4.130   #218.75.4.130是时钟服务器

2）服务器端ntp服务启动 （xntp / ntp）
# /etc/init.d/ntpd start


3）客户端只做定时同步
#crontab -e
40 4 * * * /usr/sbin/sntp -P no -r 172.22.14.11
#service cron restart