linux怎么修改时钟同步服务器

作者:狂孟安 | 发布日期:2024-05-14 06:45:46


表格介绍
| 方法 | 描述 |
|---|---|
| timedatectl | 使用 timedatectl 命令 |
| ntpdate | 使用 ntpdate 命令 |
| ntp.conf | 编辑 /etc/ntp.conf 配置文件 |
专业介绍
使用 timedatectl 命令
shell
timedatectl set-ntp timename
其中 timename 是 NTP 服务器的名称或 IP 地址。
使用 ntpdate 命令
shell
ntpdate timename
此命令会在指定的 NTP 服务器上更新系统时间。
编辑 /etc/ntp.conf 配置文件
1. 打开 /etc/ntp.conf 文件:
shell
sudo nano /etc/ntp.conf
2. 找到 server 行,并将其替换为 NTP 服务器的名称或 IP 地址:
conf
server timename
3. 保存文件并退出。
重启 NTP 服务
修改 NTP 设置后,需要重启服务:
shell
sudo systemctl restart ntpd
验证
使用 timedatectl 命令检查时间同步状态:
shell
timedatectl status