linux同步时间

linux时间有两个。一个是系统时间,一个是硬件时间!

同步国家时间的时候会出现报错:no server suitable for synchronization found

现在国家授权的   210.72.145.44   暂时不能使用

本文章主要讲ntpdate:

一、安装ntp     yum install ntp -y

二、更改时区

cp -y /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

vim /etc/sysconfig/clock

ZONE="Asia/Shanghai"
UTC=false
ARC=false

三、同步时间

/usr/sbin/ntpdate -u cn.pool.ntp.org

四、写入硬件时间

hwclock -w

 

自动时间同步

1、配置开机启动校验

vi /etc/rc.d/rc.local 

/usr/sbin/ntpdate -u cn.pool.ntp.org> /dev/null 2>&1; /sbin/hwclock -w

2、配置定时任务

00 10 * * * root /usr/sbin/ntpdate -u cn.pool.ntp.org > /dev/null 2>&1; /sbin/hwclock -w

 

posted @ 2018-04-24 18:10  大海你真大  阅读(129)  评论(0编辑  收藏  举报