1、安装ntpdate
yum install ntpdate -y
转者注:以Ubuntu为例的Debian系统安装命令如下apt-get install ntpdate。
ntpdate简单用法:
ntpdate ip
ntpdate cn.pool.ntp.org
2、date命令
date :查看当前时间,结果如下:Tue Mar 4 01:36:45 CST 2014
date -s 09:38:40 :设置当前时间,结果如下:Tue Mar 4 09:38:40 CST 2014
3、ntpdate命令
ntpdate -u cn.pool.ntp.org :网络时间同步命令
注意:若不加上-u参数, 会出现以下提示:no server suitable for synchronization found
-u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步;
4、ntp常用服务器
国内:
cn.pool.ntp.org 中国开源免费NTP服务器
ntp1.aliyun.com 阿里云NTP服务器
ntp2.aliyun.com 阿里云NTP服务器
time1.aliyun.com 阿里云NTP服务器
time2.aliyun.com 阿里云NTP服务器
国外:
time1.apple.com 苹果NTP服务器
time2.apple.com 苹果NTP服务器
time3.apple.com 苹果NTP服务器
time4.apple.com 苹果NTP服务器
time5.apple.com 苹果NTP服务器
time1.google.com 谷歌NTP服务器
time2.google.com 谷歌NTP服务器
time3.google.com 谷歌NTP服务器
time4.google.com 谷歌NTP服务器
pool.ntp.org 开源免费NTP服务器
5、加入crontab
echo “*/20 * * * * /usr/sbin/ntpdate -u ntp1.aliyun.com >/dev/null &” >> /var/spool/cron/root
转发微博 https://blog.csdn.net/weixin_44498318/article/details/115334760
博客介绍了Linux服务器时间同步相关内容。包括ntpdate的安装,在不同系统的安装命令不同;还介绍了date命令查看和设置时间,ntpdate命令进行网络时间同步及参数使用;列举了国内外常用NTP服务器;最后说明了将时间同步加入crontab的方法。
2957

被折叠的 条评论
为什么被折叠?



