Re: time zone problem with systemd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, Aug 18, 2012 at 8:50 AM, Shridhar Daithankar
<ghodechhap@xxxxxxxxxxxxxx> wrote:
> Hello,
>
> I am having trouble with time on a machine when I boot with systemd. The clock
> is ahead of actual time by the value of time zone offset.
>
> Funny thing is when I boot with initscripts, time is reported correctly.
>
> I have this problem on one machine but other machine works correctly. The only
> difference I can spot is hwclock reports local time, on the machine where time
> is correct.
>
> Whats the magic that I am missing?
>
> with systemd
> ---------------------------
> [shridhar@waman ~]$ date
> Sat Aug 18 14:23:16 IST 2012
>
> [shridhar@waman ~]$ cat /etc/timezone
> Asia/Kolkata
>
> [shridhar@waman ~]$ ls -al /etc/localtime
> lrwxrwxrwx 1 root root 32 Aug 11 02:02 /etc/localtime ->
> /usr/share/zoneinfo/Asia/Kolkata
>
> [shridhar@waman ~]$ cat /etc/adjtime
> 0.000000 0 0.000000
> 0
> UTC
>
> [shridhar@waman ~]$ grep -i hwclock /etc/rc.conf
> DAEMONS=(hwclock syslog-ng dbus network crond @cpufreq @openntpd @dnsmasq
> @sshd @laptop-mode kdm)
>
> [shridhar@waman ~]$ grep -i hardware /etc/rc.conf
>
> [root@waman shridhar]# hwclock
> Sat 18 Aug 2012 02:26:28 PM IST  -0.110228 seconds
>
> [root@waman shridhar]# hwclock -u
> Sat 18 Aug 2012 02:29:35 PM IST  -0.375925 seconds
> ---------------------------
>
> with initscripts
> ---------------------------
> [shridhar@waman ~]$ date
> Sat Aug 18 08:44:09 IST 2012
>
> [root@waman shridhar]# hwclock
> Sat 18 Aug 2012 02:33:05 PM IST  -0.146140 seconds
>
> [root@waman shridhar]# hwclock -u
> Sat 18 Aug 2012 02:33:10 PM IST  -0.438390 seconds
>
> ---------------------------
>
>
>
> --
> Regards
>  Shridhar

Your problem might be due to RTC (motherboard) clock being in local
time (generally the case if you dual-boot with Windows. Systemd
assumes that RTC is in UTC, but in case of initscripts it can be
configured to be localtime. Hence the time offset with systemd boot.

This is how I changed the clock to UTC and setup the correct time.

1. Boot into Windows and follow
https://wiki.archlinux.org/index.php/Time#UTC_in_Windows . After this
change Windows will no longer touch RTC clock at all, even if NTP is
enabled. From this moment on your RTC will be managed by any Arch.
Even after this change the RTC still remains localtime.

2. Boot into Arch and setup the files
/etc/{timezone,localtime,adjtime} according to your timezone, but with
RTC clock as UTC (very important). RTC as local time does not work
with systemd and may not work sometimes even with initscripts.

3. Run "sudo hwclock --localtime --hctosys". This (temporarily) makes
the system clock the correct time.

4. Synchronise the system (software) clock using NTP. I use chrony as
NTP daemon, but any NTP daemon should do. This is needed even after
step 3.

5. Stop the NTP daemon systemd service.

6. Run "sudo hwclock --utc --systohc". This changes the RTC time to
current UTC time.

7. Start the NTP daemon systemd service.

Regards.

Keshav

PS: Same timezone.


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux