首页  :: 新随笔  :: 管理

centos7 时间自动同步

Posted on 2019-02-28 17:53  季枫  阅读(13401)  评论(0)    收藏  举报

设置开机自动同步Internet时间,并作定时同步任务
1、修改时区

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
vim /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=false
ARC=false

2、安装并设置开机自启

yum install -y ntp
systemctl start ntpd
systemctl enable ntpd

3、配置开机启动校验

vim /etc/rc.d/rc.local
/usr/sbin/ntpdate ntp1.aliyun.com > /dev/null 2>&1; /sbin/hwclock -w

4、配置定时任务

crontab -e
0 */1 * * * ntpdate ntp1.aliyun.com > /dev/null 2>&1; /sbin/hwclock -w

  

智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |