Ubuntu操作

Ubuntu操作方法,命令
< 返回上一级

系统时间配置

系统时间,硬件时间,时间服务器ntp

子节点:

-- 暂无子节点 --

内容:

ntp服务:安装ntp

ntp服务

ubuntu 安装命令:

sudo apt-get install ntp

启动命令:

/etc/init.d/ntp start

查看NTP服务的运行状况:

watch ntpq -p

配置文件:

/etc/ntp.conf

允许时间同步网段:

# Clients from this (example!) subnet have unlimited access, but only if

# cryptographically authenticated.

#restrict 192.168.123.0 mask 255.255.255.0 notrust

参数有以下几个:

ignore :关闭所有的 NTP 联机服务

nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。

notrust :客户端除非通过认证,否则该客户端来源将被视为不信任子网

noquery :不提供客户端的时间查询

注意:如果参数没有设定,那就表示该 IP (或子网)没有任何限制!


ntp客户端:ntpdate

ntp同步系统时间

ubuntu 安装 ntpdate :

sudo apt install ntpdate

同步时间:

ntpdate 192.168.0.123

查询发现导致错误的原因:

ntpdate -d

LINUX做为客户端自动同步时间

LINUX做为客户端自动同步时间

LINUX做为客户端自动同步时间

如果想定时进行时间校准,可以使用crond服务来定时执行。

1,编辑 /etc/crontab 文件

加入下面一行:

30 8 * * * root /usr/sbin/ntpdate 192.168.166.100; /sbin/hwclock -w
#192.168.0.1是NTP服务器的IP地址

2,然后重启crond服务

service crond restart

这样,每天 8:30 Linux 系统就会自动的进行网络时间校准。