Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Universal time and local time always wrong [Solved]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
Lu Tze
n00b
n00b


Joined: 21 Nov 2005
Posts: 22
Location: Tugadogalong

PostPosted: Wed Feb 26, 2014 11:05 am    Post subject: Universal time and local time always wrong [Solved] Reply with quote

First off, I apologise if this has been discussed/solved before - I did search the forum before posting.

Next, some background info. I recently bought a new Acer Aspire V5-573G (in case this is relevant). I did a fresh Gentoo installation, initially with OpenRC, but then I switched to systemd just to try it out. I have an older Dell laptop running Gentoo, which still has OpenRC. A millenium ago I had a dual boot with Windows on the old laptop, and so I had (and still have) clock="local" in /etc/conf.d/hwclock. I never had any troubles with these clock settings, so I ported them to the new laptop. Then I decided to switch to systemd on the new laptop, but when I tried to set the clock to "local", timedatectl complained that this is not fully supported and can be tricky with DST. So I went with the recommended UTC, and that's where the problems began.

In a nutshell, both UTC and local time are wrong on boot. I live in Australia, and the local time is currently GMT +1100, but here is what I get when I boot the laptop (the actual local time is 8:34 on 26 Feb).

Code:


# timedatectl

      Local time: Tue 2014-02-25 21:34:52 EST
  Universal time: Tue 2014-02-25 10:34:52 UTC
        RTC time: Tue 2014-02-25 21:34:51
        Timezone: Australia/Sydney (EST, +1100)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2013-10-06 01:59:59 EST
                  Sun 2013-10-06 03:00:00 EST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2014-04-06 02:59:59 EST
                  Sun 2014-04-06 02:00:00 EST


Running ntpd -s sets things right...

Code:

# timedatectl

      Local time: Wed 2014-02-26 08:35:10 EST
  Universal time: Tue 2014-02-25 21:35:10 UTC
        RTC time: Tue 2014-02-25 21:35:09
        Timezone: Australia/Sydney (EST, +1100)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2013-10-06 01:59:59 EST
                  Sun 2013-10-06 03:00:00 EST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2014-04-06 02:59:59 EST
                  Sun 2014-04-06 02:00:00 EST



...but only until the next reboot, when everything goes back to chaos. I checked the BIOS clock and it shows the correct UTC time, so something somewhere is not setting the system clock correctly. /etc/localtime is correctly symlinked to /usr/share/zoneinfo/Australia/Sydney, I even re-emerged sys-libs/timezone-data and recreated the symlink. These are the things I have tried so far, to no avail:


  • hwclock -w
  • hwclock --set --u
  • hwclock --date
  • timedatectl set-time
  • timedatectl --adjust-system-clock
  • timedatectl set-local-rtc 0
  • Switched back to OpenRC, set clock="UTC", clock_systohc="YES" and clock_hctosys="YES" in /etc/conf.d/hwclock and rebooted. Same result.
  • Selected RTC_HCTOSYS in the kernel (and of course ran make && make modules_install and copied the new kernel into /boot). Same result.
  • Selected all the RTC drivers in the kernel as built-in (including RTC_DRV_CMOS, which was selected by default anyway). Same result.


I also tried chanting and voodoo, but it didn't help either. Anyone who may have the slightest idea as to why this is happening, please let me know. Here is some system info:

.config - RTC section:

Code:

#
# iptables trigger is under Netfilter config (LED target)
#
CONFIG_LEDS_TRIGGER_TRANSIENT=m
CONFIG_LEDS_TRIGGER_CAMERA=m
# CONFIG_ACCESSIBILITY is not set
# CONFIG_INFINIBAND is not set
CONFIG_EDAC=y
CONFIG_EDAC_LEGACY_SYSFS=y
# CONFIG_EDAC_DEBUG is not set
# CONFIG_EDAC_MM_EDAC is not set
CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
# CONFIG_RTC_DEBUG is not set

#
# RTC interfaces
#
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
# CONFIG_RTC_DRV_TEST is not set

#
# I2C RTC drivers
#
CONFIG_RTC_DRV_DS1307=y
CONFIG_RTC_DRV_DS1374=y
CONFIG_RTC_DRV_DS1672=y
CONFIG_RTC_DRV_DS3232=y
CONFIG_RTC_DRV_MAX6900=y
CONFIG_RTC_DRV_RS5C372=y
CONFIG_RTC_DRV_ISL1208=y
CONFIG_RTC_DRV_ISL12022=y
CONFIG_RTC_DRV_X1205=y
CONFIG_RTC_DRV_PCF8523=y
CONFIG_RTC_DRV_PCF8563=y
CONFIG_RTC_DRV_PCF8583=y
CONFIG_RTC_DRV_M41T80=y
CONFIG_RTC_DRV_M41T80_WDT=y
CONFIG_RTC_DRV_BQ32K=y
CONFIG_RTC_DRV_S35390A=y
CONFIG_RTC_DRV_FM3130=y
CONFIG_RTC_DRV_RX8581=y
CONFIG_RTC_DRV_RX8025=y
CONFIG_RTC_DRV_EM3027=y
CONFIG_RTC_DRV_RV3029C2=y

#
# SPI RTC drivers
#
CONFIG_RTC_DRV_M41T93=y
CONFIG_RTC_DRV_M41T94=y
CONFIG_RTC_DRV_DS1305=y
CONFIG_RTC_DRV_DS1390=y
CONFIG_RTC_DRV_MAX6902=y
CONFIG_RTC_DRV_R9701=y
CONFIG_RTC_DRV_RS5C348=y
CONFIG_RTC_DRV_DS3234=y
CONFIG_RTC_DRV_PCF2123=y
CONFIG_RTC_DRV_RX4581=y

#
# Platform RTC drivers
#
CONFIG_RTC_DRV_CMOS=y
CONFIG_RTC_DRV_DS1286=y
CONFIG_RTC_DRV_DS1511=y
CONFIG_RTC_DRV_DS1553=y
CONFIG_RTC_DRV_DS1742=y
CONFIG_RTC_DRV_STK17TA8=y
CONFIG_RTC_DRV_M48T86=y
CONFIG_RTC_DRV_M48T35=y
CONFIG_RTC_DRV_M48T59=y
CONFIG_RTC_DRV_MSM6242=y
CONFIG_RTC_DRV_BQ4802=y
CONFIG_RTC_DRV_RP5C01=y
CONFIG_RTC_DRV_V3020=y
CONFIG_RTC_DRV_DS2404=y

#
# on-CPU RTC drivers
#

#
# HID Sensor RTC drivers
#
CONFIG_RTC_DRV_HID_SENSOR_TIME=y
CONFIG_DMADEVICES=y
# CONFIG_DMADEVICES_DEBUG is not set


make.conf:

Code:

### system ###

CFLAGS="-march=core-avx2 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
MAKEOPTS="-j5"

### /system ###

### sync ###

#GENTOO_MIRRORS="http://ftp.swin.edu.au/gentoo"
GENTOO_MIRRORS="ftp://ftp.swin.edu.au/gentoo"
#GENTOO_MIRRORS="http://ftp.jaist.ac.jp/pub/Linux/Gentoo/"
#GENTOO_MIRRORS="ftp://ftp.jaist.ac.jp/pub/Linux/Gentoo/"
#GENTOO_MIRRORS="http://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/"

#SYNC="rsync://rsync3.jp.gentoo.org/gentoo-portage"
#SYNC="rsync://rsync16.de.gentoo.org/gentoo-portage"
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"

### /sync ###

### portage ###

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"

### /portage ###

### use ###

USE="-gnome -consolekit -semantic-desktop \
acpi alsa avx avx2 \
bindist \
cjk cuda cups cairo curl \
dbus \
exif \
ffmpeg fontconfig fontforge \
gimp glamor gtk2 gtk3 gif \
idn imagemagick \
jack jpeg jpeg2k \
kde \
lame \
mmx mmxext mysql \
nvidia \
ogg opengl opencl openexr \
pic pdf python python2 python3 png pango \
qalculate qt4 qt3support \
scim sse sse2 sse3 ssse3 sse4_1 sqlite ssl svg systemd \
theora threads twolame tiff truetype type3 \
udisks unicode usb \
v4l v4l2 vaapi vdpau vhosts vorbis \
X xine"

### /use ###

VIDEO_CARDS="intel nvidia modesetting"
INPUT_DEVICES="evdev keyboard mouse synaptics"
LINGUAS="en_GB"


emerge --info:

Code:

Portage 2.2.7 (default/linux/amd64/13.0, gcc-4.7.3, glibc-2.17, 3.10.25-gentoo x86_64)
=================================================================
System uname: Linux-3.10.25-gentoo-x86_64-Intel-R-_Core-TM-_i5-4200U_CPU_@_1.60GHz-with-gentoo-2.2
KiB Mem:    12186300 total,  11476640 free
KiB Swap:   12694524 total,  12694524 free
Timestamp of tree: Wed, 19 Feb 2014 12:15:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-lang/python:          2.7.5-r3, 3.2.5-r3, 3.3.3
dev-util/cmake:           2.8.11.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core-avx2 -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=core-avx2 -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://ftp.swin.edu.au/gentoo"
LANG="en_GB.UTF-8"
LC_ALL="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=""
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"
USE="X acl acpi alsa amd64 avx avx2 berkdb bindist bzip2 cairo cjk cli cracklib crypt cuda cups curl cxx dbus dri exif ffmpeg fontconfig fontforge fortran gdbm gif gimp glamor gtk2 gtk3 iconv idn imagemagick ipv6 jack jpeg jpeg2k kde lame mmx mmxext modules multilib mysql ncurses nls nptl nvidia ogg opencl openexr opengl openmp pam pango pcre pdf pic png python python2 python3 qalculate qt3support qt4 readline scim session sqlite sse sse2 sse4 sse4.1 sse4.2 sse4a sse4b ssl ssse3 svg systemd tcpd theora threads tiff truetype twolame type3 udisks unicode usb v4l v4l2 vaapi vdpau vhosts vorbis xine zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en_GB" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby18" USERLAND="GNU" VIDEO_CARDS="intel nvidia modesetting" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON


Thank you in advance!
_________________
"My brother sent me a postcard the other day with this big satellite photo of the entire Earth on it. On the back it said: "Wish you were here"" - Steven Wright


Last edited by Lu Tze on Thu Feb 27, 2014 11:24 am; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9677
Location: almost Mile High in the USA

PostPosted: Wed Feb 26, 2014 11:05 pm    Post subject: Reply with quote

I'd look into custom init scripts that may be futzing with the clock.

Your RTC looks right though? It appears to match UTC which is what you intended, but for some reason on boot, it's reading it and assuming it's localtime...

IIRC on my systemd install it looks like it's correct, I better check, maybe I have the same problem...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Lu Tze
n00b
n00b


Joined: 21 Nov 2005
Posts: 22
Location: Tugadogalong

PostPosted: Thu Feb 27, 2014 9:23 am    Post subject: Reply with quote

Thank you for the reply, eccerr0r.

It's a fresh install, so I have no custom init scripts. Besides, OpenRC init scripts shouldn't interfere with systemd, should they? In any case, the problem persisted when I switched temporarily to OpenRC, so I don't think it's related to the init system at all. The machine is new and the CMOS clock is perfectly accurate, so it's not a hardware problem either. And yes, you are right - for some reason the hardware clock is assumed to represent the local time and the universal time seems to be calculated from that. Very odd.
_________________
"My brother sent me a postcard the other day with this big satellite photo of the entire Earth on it. On the back it said: "Wish you were here"" - Steven Wright
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Thu Feb 27, 2014 10:14 am    Post subject: Reply with quote

systemd's handling of clock is a mess and - as most things of systemd - you cannot replace it with other tools of your choice.

RTC Time and universal time displayed are the same: This is good.

Setting RTC_HCTOSYS in kernel is probably a good idea, so you need not rely on systemd to do this. In openrc, set clock_hctosys="NO" (because it should be done by the kernel).

Once the time is fetched correctly from the net, remove /etc/adjtime and call
Code:
hwclock --systohc --utc --noadjfile
You might also write a systemd service which runs this command automatically on shutdown. (Putting clock_systohc=YES should do a similar thing for openrc)
Back to top
View user's profile Send private message
Lu Tze
n00b
n00b


Joined: 21 Nov 2005
Posts: 22
Location: Tugadogalong

PostPosted: Thu Feb 27, 2014 11:23 am    Post subject: Reply with quote

mv, thank you for the feedback - you nailed it. I looked around again and found this:

https://forums.gentoo.org/viewtopic-t-936216-start-0.html

Seems like a variation on a theme. I followed the suggestion to set clock_hctosys="NO" in that thread, switched back to OpenRC et voilà, lo and behold, the time was correct. This is essentially what you suggested too. I do have RTC_HCTOSYS in the kernel.

So I've switched back to good ol' OpenRC for the time being. Not sure why this is not given more attention, it's a rather annoying and obscure problem. Not sure if it's relevant, but in that thread above, there is a link to a bug that seems to be mostly ignored:

https://bugs.gentoo.org/show_bug.cgi?id=434410

Marking as solved, although I'm still not sure what exactly the problem was.
_________________
"My brother sent me a postcard the other day with this big satellite photo of the entire Earth on it. On the back it said: "Wish you were here"" - Steven Wright
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum