Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux General Discussion (http://www.linux-archive.org/archlinux-general-discussion/)
-   -   time zone problem with systemd (http://www.linux-archive.org/archlinux-general-discussion/695224-time-zone-problem-systemd.html)

Shridhar Daithankar 08-18-2012 03:20 AM

time zone problem with systemd
 
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

Brandon Watkins 08-18-2012 01:42 PM

time zone problem with systemd
 
On Fri, Aug 17, 2012 at 11:20 PM, Shridhar Daithankar <
ghodechhap@ghodechhap.net> 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
>
Make sure you symlink your timezone to /etc/localtime as described here:
https://wiki.archlinux.org/index.php/Beginner%27s_Guide#Timezone

Brandon Watkins 08-18-2012 01:44 PM

time zone problem with systemd
 
On Fri, Aug 17, 2012 at 11:20 PM, Shridhar Daithankar <
ghodechhap@ghodechhap.net> 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
>
Apologies, looks like you already did that (I just woke up and must have
scrolled past it, heh )

Keshav P R 08-18-2012 02:34 PM

time zone problem with systemd
 
On Sat, Aug 18, 2012 at 8:50 AM, Shridhar Daithankar
<ghodechhap@ghodechhap.net> 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.

Shridhar Daithankar 08-18-2012 06:05 PM

time zone problem with systemd
 
On Saturday 18 Aug 2012 8:04:58 PM Keshav P R wrote:
> 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.

Thank you very much for the precise problem description. This used to be a
windows laptop and the BIOS clock reported correct time.

The other machine where time was correct, the BIOS clock was behind 5.30
hours.

> 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.

I rebooted the machine, set the bios clock correctly i.e. 5.30 hours behind
local time and now I have correct clock even after couple of reboots.

That's sufficient?
--
Regards
Shridhar


All times are GMT. The time now is 01:59 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.