首页 > 系统相关 >Linux同步网络时间

Linux同步网络时间

时间:2022-08-17 16:11:53浏览次数:61  
标签:同步 etc ntp 网络 BIOS 时间 Linux 服务器

CentOS服务器
1、获取当前系统时间
# date

2、安装ntp
# yum -y install ntp

3、修改时区
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

4、同步网络时间
# ntpdate -u ntp.api.bz

ntpdate表示网络同步时间
-u 表示可以越过防火墙与主机同步。可man ntpdate查看手册
ntp.api.bz是NTP服务器(上海)。
5、修改系统BIOS时间

# hwclock -w

当我们进行完 Linux 时间的校时后,还需要以 hwclock -w 来更新 BIOS 的时间,因为每次开机的时候,系统会重新由 BIOS 将时间读出来,所以, BIOS 才是重要的时间依据。

Ubunto服务器20.04 同步网络时间
1、使用timedatectl命令修改时区
sudo timedatectl set-timezone Asia/Shanghai
2、运行命令,验证修改
timedatectl
3、修改时间为24小时制显示
sudo vi /etc/default/locale
#添加如下一行
echo "LC_TIME=en_DK.UTF-8" >> /etc/default/locale
4、重启服务器

标签:同步,etc,ntp,网络,BIOS,时间,Linux,服务器
From: https://www.cnblogs.com/keyL/p/16595575.html

相关文章