# 时间设置

主要针对ubuntu系统的时间设置

# 查看当前时间


date

1
2
3

# timedatectl使用


# 查看当前时区 及时间设置
timedatectl

# 设置时区 e.g. Asia/Shanghai
sudo timedatectl set-timezone Asia/Shanghai


#手动设置时间
sudo timedatectl set-time "2019-12-12 12:12:12"

#开启ntp服务
sudo timedatectl set-ntp true
#关闭ntp服务
sudo timedatectl set-ntp false

# 查看时间同步状态
timedatectl timesync-status

# 验证时间配置
timedatectl show-timesync --all


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

# timesyncd服务

# 查看timesyncd服务状态 如果看到Initial synchronization to time server or Synchronized to time server则表示时间同步成功
systemctl status systemd-timesyncd.service
# 启动timesyncd服务
systemctl start systemd-timesyncd.service
# 停止timesyncd服务
systemctl stop systemd-timesyncd.service
# 重启timesyncd服务
systemctl restart systemd-timesyncd.service
1
2
3
4
5
6
7
8

# timesyncd配置文件

# 配置文件路径
/etc/systemd/timesyncd.conf
1
2

# 硬件时间同步

# 查看硬件时间
sudo hwclock --show

# 将系统时间同步到硬件时间
sudo hwclock --systohc
# 将硬件时间同步到系统时间
sudo hwclock --hctosys
1
2
3
4
5
6
7

deepin 时间和时区 (opens new window)

Last Updated: 7/10/2024, 12:35:06 AM