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、重启服务器

posted @ 2022-08-17 16:03  华华华华华华华  阅读(491)  评论(0编辑  收藏  举报