CentOS7.6 同步时间ntpdate

安装ntpdate
yum install -y ntpdate

ntpdate的用法:
# ntpdate ip
# ntpdate 210.72.145.44
# ntpdate cn.pool.ntp.org
# ntpdate ntp1.aliyun.com

附二级时间服务器列表:

ntp1.aliyun.com 阿里云
0.pool.ntp.org 有域名负载均衡
0.cn.pool.ntp.org 有域名负载均衡
ntp.tuna.tsinghua.edu.cn 清华大学
time.windows.com 微软

vim /etc/crontab
添加计划任务

*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com
上面为每5分钟同步一次

8 11 * * * root (/usr/sbin/ntpdate ntp1.aliyun.com && /sbin/hwclock -w) &> /var/log/ntpdate.log
上面为11点08分同步一次,并把记录写进日志

*/2 * * * * root (/usr/sbin/ntpdate ntp1.aliyun.com && /sbin/hwclock -w) &>> /var/log/ntpdate.log
上面为每2分钟同步一次,并追加记录进日志

posted @ 2021-09-08 14:21  昵称昵称昵称  阅读(283)  评论(0编辑  收藏  举报