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

简介: 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


相关文章
|
19天前
|
Web App开发 Linux 网络安全
工作中常用到的Linux命令
工作中常用到的Linux命令
|
19天前
|
Web App开发 Java Linux
Linux之Shell基本命令篇
Linux之Shell基本命令篇
Linux之Shell基本命令篇
|
6天前
|
机器学习/深度学习 缓存 监控
linux查看CPU、内存、网络、磁盘IO命令
`Linux`系统中,使用`top`命令查看CPU状态,要查看CPU详细信息,可利用`cat /proc/cpuinfo`相关命令。`free`命令用于查看内存使用情况。网络相关命令包括`ifconfig`(查看网卡状态)、`ifdown/ifup`(禁用/启用网卡)、`netstat`(列出网络连接,如`-tuln`组合)以及`nslookup`、`ping`、`telnet`、`traceroute`等。磁盘IO方面,`iostat`(如`-k -p ALL`)显示磁盘IO统计,`iotop`(如`-o -d 1`)则用于查看磁盘IO瓶颈。
|
16天前
|
NoSQL Linux Shell
常用的 Linux 命令
常用的 Linux 命令
36 9
|
3天前
|
监控 Linux Windows
50个必知的Linux命令技巧,你都掌握了吗?(下)
50个必知的Linux命令技巧,你都掌握了吗?(下)
|
3天前
|
Linux Shell Windows
Linux 常用基本命令
Linux 常用基本命令
|
4天前
|
Ubuntu Linux Shell
linux免交互登陆远程主机并执行命令(密钥对和Expect)
linux免交互登陆远程主机并执行命令(密钥对和Expect)
|
4天前
|
Linux
【Linux】常用命令
【Linux】常用命令
24 0
|
4天前
|
安全 Ubuntu Linux
Linux 网络操作命令Telnet
Linux 网络操作命令Telnet
17 0
Linux 网络操作命令Telnet
|
5天前
|
Linux 数据安全/隐私保护
Linux常用命令实例带注释
Linux常用命令实例带注释
30 0