centos6.8 同步时间的方法

linux简易教程

centos6.8 同步时间的方法

2024-03-14 11:48


                                            




设置系统时区

# 设置 上海 UTC+8 时区

 

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

# 设置 香港 UTC+8 时区

 

sudo ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime

 

# 设置 台北 UTC+8 时区

 

sudo ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime

 

# 设置 北美东部标准 UTC-5 时区

 

sudo ln -sf /usr/share/zoneinfo/EST /etc/localtime

 

# 设置 协调世界时 UTC 时区

 

sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime

 

设置硬件时区

 

如需修改硬件设备时区,编辑下面文件。

 

sudo vi /etc/sysconfig/clock

 

修改其中的 ZONE 参数值,并额外添加两行,将 UTC(BIOS 时间) 和 ARC 参数设置为 false。

 

ZONE="Asia/Shanghai"

 

UTC=false

 

ARC=false

 

更新硬件时间。用sudo hwclock命令查询验证(date查询的是系统时间)。

 

sudo hwclock --systohc --localtime

 

定期同步时间

 

如果需要定期检查调准时间,可以设置 NTP 时间同步服务。

 

# 安装 NTP 软件包

 

sudo yum -y install ntp

 

# 添加可信任的 NTP 时间同步服务器

 

sudo ntpdate -d asia.pool.ntp.org

 

# 重启刷新 NTP 服务

 

sudo service ntpd restart

 

如果启用了系统防火墙并采取白名单方式管理端口,别忘了添加允许 NTP 所使用的 123/UDP 端口。

————————————————

原文链接:https://blog.csdn.net/u010109949/article/details/128577393