You are not logged in.

#1 2011-06-25 21:19:18

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

ntpd problem [SOLVED]

Hi people.

I am using ntpd (network time protocol daemon) and I have a problem.

rc.conf:
Hardwareclock is set to UTC and timezone is set to Europe/Belgrade

So I am in GMT+1, but every time I start-up the computer clock is 2 hours forward from my time zone.
If its 2 pm, it says its 4 pm.

As I am using ntpd as a daemon it synchronizes the time when I connect to the internet. I dont like it, because almost 5 minutes passes until ntpd synchronizes the time.

Is there a way to display correct time zone using UTC?

Last edited by webmasteryoda (2011-06-26 00:16:48)

Offline

#2 2011-06-25 22:42:38

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: ntpd problem [SOLVED]

Take a look at this article on Time Skew.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2011-06-25 23:08:35

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

ewaller wrote:

Take a look at this article on Time Skew.

I dont understand.

Here s my /etc/rc.d/hwclock

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case $HARDWARECLOCK in
    UTC) HWCLOCK_PARAMS="--utc";;
    localtime) HWCLOCK_PARAMS="--localtime";;
    *) HWCLOCK_PARAMS="";;
esac

case "$1" in
    start)
        if [[ $HWCLOCK_PARAMS ]]; then
            status "Adjusting Hardware Clock" \
                /sbin/hwclock --adjust
            stat_busy "Setting System Clock"
            /sbin/hwclock --hctosys $HWCLOCK_PARAMS || stat_die
            stat_done
            # Note: This also enables /etc/cron.hourly/adjtime
            add_daemon hwclock
        fi
        ;;
    stop)
        if [[ $HWCLOCK_PARAMS ]]; then
            stat_busy "Saving System Clock"
            /sbin/hwclock --systohc $HWCLOCK_PARAMS || stat_die
            stat_done
        fi
        rm_daemon hwclock
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"
esac

Offline

#4 2011-06-25 23:12:57

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: ntpd problem [SOLVED]

Delete /var/lib/hwclock/adjtime and see if the problem goes away.  It will be recreated with valid values that are tuned over time.  If this file contains values that are really wrong, you will see large errors.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2011-06-25 23:20:00

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

ewaller wrote:

Delete /var/lib/hwclock/adjtime and see if the problem goes away.  It will be recreated with valid values that are tuned over time.  If this file contains values that are really wrong, you will see large errors.

I deleted it.

Its 2 hours forward again. So its not a solution.

Any ideas?

Offline

#6 2011-06-25 23:25:19

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: ntpd problem [SOLVED]

Can you post the output of:
date
and of:
date -u
and of:
hwclock


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2011-06-25 23:28:49

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

ewaller wrote:

Can you post the output of:
date
and of:
date -u
and of:
hwclock

date:
Sun Jun 26 01:27:03 CEST 2011
date -u:
Sat Jun 25 23:27:33 UTC 2011
hwclock:
Sun 26 Jun 2011 01:28:11 AM CEST  -0.917821 seconds

Its after synchronizing with ntpd

Offline

#8 2011-06-25 23:50:08

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

Just to add...

when I change from UTC to locale, everythings ok, but I have multiboot and I read about recommendation to move to UTC. Thats why I switched to it...

Offline

#9 2011-06-25 23:55:55

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: ntpd problem [SOLVED]

Can you post your /etc/rc.conf ??


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#10 2011-06-25 23:57:21

stqn
Member
Registered: 2010-03-19
Posts: 1,191
Website

Re: ntpd problem [SOLVED]

Your hwclock is in localtime and not UTC, which might explain your 2 hours offset.
You could try this:

hwclock --utc --systohc

to set it to UTC.

In order for ntpd to set your clock earlier than 5 min after boot, maybe waiting for the network to be up before launching the daemon could help? I have this in /etc/rc.local:

(sleep 10 && /etc/rc.d/openntpd start) &

And then... In rc.conf we have this comment:

# If something other takes care of your hardware clock (ntpd, dual-boot...)
# you should disable 'hwclock' here.

I'm not sure if/when the hw clock is read then, when the hwclock daemon is disabled... But I have disabled it anyway.

Edit: if you multiboot with Windows I think you should be using localtime.

Last edited by stqn (2011-06-26 00:01:01)

Offline

#11 2011-06-25 23:59:17

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

ewaller wrote:

Can you post your /etc/rc.conf ??

Sure. Here it is:

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# DAEMON_LOCALE: Set the locale during daemon startup and during the boot
#   process. If set to 'no', the C locale will be used.
# HARDWARECLOCK: set to "UTC" or "localtime", any other value will result
#   in the hardware clock being left untouched (useful for virtualization)
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.UTF-8"
DAEMON_LOCALE="no"
HARDWARECLOCK="UTC"
TIMEZONE="Europe/Berlin"
KEYMAP="croat"
CONSOLEFONT="cp1250"
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
#MOD_BLACKLIST=() #deprecated
MODULES=(acpi-cpufreq cpufreq_ondemand cpufreq_powersave fglrx fuse !ath5k)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="archyoda"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
#   - prefix an entry in INTERFACES with a ! to disable it
#   - no hyphens in your interface names - Bash doesn't like it
# 
# DHCP:     Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#

#Static IP example
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
#eth0="dhcp"
#wlan0="dhcp"
INTERFACES=(!eth0 !wlan0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
#   - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)
 
# Setting this to "yes" will skip network shutdown.
# This is required if your root device is on NFS.
NETWORK_PERSIST="no"

# Enable these network profiles at boot-up.  These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
#   - set to 'menu' to present a menu during boot-up (dialog package required)
#   - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(main)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
#   - prefix a daemon with a ! to disable it
#   - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng dbus laptop-mode !hibernate-cleanup !acpid networkmanager !network !netfs crond alsa hal vboxdrv !fam ntpd gdm)

Offline

#12 2011-06-26 00:16:03

webmasteryoda
Member
From: Serbia
Registered: 2010-03-20
Posts: 115
Website

Re: ntpd problem [SOLVED]

stqn wrote:

Your hwclock is in localtime and not UTC, which might explain your 2 hours offset.
You could try this:

hwclock --utc --systohc

to set it to UTC.

Yap. Its solved.
Thx to both of you.

Offline

Board footer

Powered by FluxBB