0
点赞
收藏
分享

微信扫一扫

Linux:使用ntpdate命令同步更新系统时间

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

注:双引号内指令分别代表​​min hour dom mon dow user command.​

举报

相关推荐

0 条评论