$ timedatectl status
Local time: 五 2016-10-21 01:34:20 CST
Universal time: 四 2016-10-20 17:34:20 UTC
RTC time: 四 2016-10-20 17:34:20
Time zone: Asia/Shanghai (CST, +0800) NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
$ timedatectl set-ntp true
再看状态:
$ timedatectl status
Local time: 五 2016-10-21 01:36:57 CST
Universal time: 四 2016-10-20 17:36:57 UTC
RTC time: 四 2016-10-20 17:36:58
Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
打开 /etc/systemd/timesyncd.conf:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# See timesyncd.conf(5) for details
[Time]
#Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
加入时间更新服务器:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# See timesyncd.conf(5) for details
[Time]
#Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
Servers=ntp.ubuntu.com
这样每次开机就会从ntp.ubuntu.com自动更新时间了。
参见:How to manage system services on Debian Jessie
https://blog.sleeplessbeastie.eu/2015/04/27/how-to-manage-system-services-on-debian-jessie/