Linux 自动同步服务器时间
2018-03-21 21:47
323 查看
网络时间服务器
首先得确保这些服务器都能ping通否则是无法时间同步的。否则会报错“no server suitable for synchronization found”
中国国家授时中心:210.72.145.44 ----暂时无法使用
NTP服务器(上海) :ntp.api.bz
中国ntp服务器:cn.pool.ntp.org
pool.ntp.org
时间同步工具
rdate:rdate -s
ntpdate:ntpdate -u(使用-u参数会返回误差,也可以使用-s)
以上两个工具都可以用来同步网络时间服务器,centos默认都有安装,两个工具的使用方法都很简单,本章主要介绍ntpdate工具。如果没有安装安装方法如下:
yum -y install ntp
同步时间
1.修改时区
cp -y /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
vim /etc/sysconfig/clock
ZONE="Asia/Shanghai"UTC=falseARC=false
2.同步时间
/usr/sbin/ntpdate -u cn.pool.ntp.org
3.写入硬件时间
服务器每次重启都会参考硬件的时间,所以需要将当前系统的时间写入到硬件。
查看当前硬件时间:
hwclock -r
[root@localhost ~]# hwclock -r Thu 12 May 2016 08:05:43 PM CST -0.674165 seconds
写入硬件时间:
hwclock -w
自动时间同步
1.配置开机启动校验
vim /etc/rc.d/rc.local
/usr/sbin/ntpdate -u cn.pool.ntp.org> /dev/null 2>&1; /sbin/hwclock -w
2.配置定时任务
vim /etc/crontab
00 10 * * * root /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w
或者
crontab -e
00 10 * * * /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w
安装定时服务crontab参考:https://www.geek-share.com/detail/2672575761.html
相关文章推荐
- Linux 自动同步服务器时间
- CentOS/Linux 自动同步服务器时间
- linux ntp 服务器,时间同步
- CentOS自动同步互联网服务器时间
- 自动调整linux系统时间和时区与Internet时间同步
- 如何同步两台linux服务器的时间
- Linux 局域网内服务器时间同步
- linux自动同步时间的方法
- LInux下可以使用命令自动与网络的NTP服务器同步时间 CSDN验证码验证失败问题解决
- Linux同步时间服务器
- 本机时间自动与Internet时间服务器同步出错怎么办?
- linux 时间自动同步
- 自动调整linux系统时间和时区与Internet时间同步
- 自动调整linux系统时间和时区与Internet时间同步
- linux开机实现时间自动同步
- linux时间自动同步
- windows2003服务器,时间每隔1小时自动同步一次
- linux同步ntpd服务器时间方式
- 设置CentOS Linux系统时间自动同步
- Linux配置自动时间同步