我刚刚安装了 Ubuntu 16.04.1 来替代 Windows 8.1。但系统时间比实际时间早了 +5:30。我来自印度,UTC 偏移量为 +5:30。通过运行 hwclock,我发现我的系统将硬件时钟解释为 UTC,而它实际上是本地时间。我尝试编辑 /etc/default/rcS 文件(按照硬件时钟使用 UTC 时间)。但是 rcS 文件不包含 UTC 条目。文件内容如下所示。该怎么办?
hwclock --debug的结果:
hwclock from util-linux 2.27.1
Using the /dev interface to the clock.
Last drift adjustment done at 1474290330 seconds after 1969
Last calibration done at 1474290330 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2016/09/19 18:55:12
Hw clock time : 2016/09/19 18:55:12 = 1474291512 seconds since 1969
Time since last adjustment is 1182 seconds
Calculated Hardware Clock drift is 0.000000 seconds
Monday 19 September 2016 06:55:11 PM IST .186866 seconds
rcS 文件:
#
# /etc/default/rcS
#
# Default settings for the scripts in /etc/rcS.d/
#
# For information about these variables see the rcS(5) manual page.
#
# This file belongs to the "initscripts" package.
# delete files in /tmp during boot older than x days.
# '0' means always, -1 or 'infinite' disables the feature
#TMPTIME=0
# spawn sulogin during boot, continue normal boot if not used in 30 seconds
#SULOGIN=no
# do not allow users to log in until the boot has completed
#DELAYLOGIN=no
# be more verbose during the boot process
#VERBOSE=no
# automatically repair filesystems with inconsistencies during boot
#FSCKFIX=no
答案1
如果文件/etc/adjtime不存在,systemd 假定硬件时钟设置为 UTC。
可以使用以下命令查询和设置硬件时钟timedatectl命令。要将硬件时钟时间标准更改为本地时间,请使用:
sudo timedatectl set-local-rtc 1
如果您想恢复硬件时钟的 UTC,请执行以下操作:
sudo timedatectl set-local-rtc 0
这些将产生/etc/adjtime并相应更新 RTC;无需进一步配置。
答案2
如果您不打算再次使用 Windows,我建议只设置时间(date -s
命令)并在硬件时钟中保留 UTC。