You are not logged in.

#1 2011-08-05 17:44:13

rnabioullin
Member
Registered: 2010-10-02
Posts: 24

ntpd and syslog-ng boot sequence circular dependency

A comment in the default /etc/rc.conf states that the hwclock daemon (which apparently syncs the software clock with the RTC after compensation) should be disabled if ntpd is to be used. However, it appears that ntpd requires syslog-ng for logging, and syslog-ng requires the current time for accurate timestamps. Invoking ntpd before syslog-ng will prevent log messages generated by ntpd from being logged (until syslog-ng is invoked) and invoking syslog-ng before ntpd will result in inaccurate timestamps (until ntpd is invoked and syncs the software clock with the RTC, which might not even be guaranteed in time for syslog-ng).

Is my reasoning correct?

Offline

#2 2011-08-05 18:59:29

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: ntpd and syslog-ng boot sequence circular dependency

rnabioullin wrote:

invoking syslog-ng before ntpd will result in inaccurate timestamps

Potentially possible, but not a big deal.

*One* of them's got to be started first, so it should be the syslogger.

Offline

#3 2011-08-05 20:27:07

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

Re: ntpd and syslog-ng boot sequence circular dependency

You're probably right. Maybe the solution is to create a clock daemon that simply calls "hwclock --hctosys" at startup and "hwclock --systohc" at shutdown. I'm just calling these in rc.local and rc.shutdown.local... But if your hw clock battery is dead it won't help.

Offline

#4 2011-08-06 21:33:35

rowdog
Member
From: East Texas
Registered: 2009-08-19
Posts: 118

Re: ntpd and syslog-ng boot sequence circular dependency

If you are trying to work around a dead battery, you could call ntpdate to set the clock once, start syslog, then start ntpd.

Offline

#5 2011-08-08 18:05:33

drrossum
Member
From: Chicago
Registered: 2009-02-24
Posts: 82

Re: ntpd and syslog-ng boot sequence circular dependency

stqn wrote:

You're probably right. Maybe the solution is to create a clock daemon that simply calls "hwclock --hctosys" at startup and "hwclock --systohc" at shutdown. I'm just calling these in rc.local and rc.shutdown.local... But if your hw clock battery is dead it won't help.

rc.local is run later than the daemon startup, so that won't help setting the times right for the syslog.

I use a modified hwclock daemon script:

case "$1" in
    start)
        #add_daemon hwclock;;
        hwclock --adjust
        hwclock --hctosys;;
    stop)
        case $HARDWARECLOCK in
            #UTC) hwclock --adjust --utc;;
            #localtime) hwclock --adjust --localtime;;
            #"") hwclock --adjust;;
            UTC) hwclock --systohc --utc;;
            localtime) hwclock --systohc --localtime;;
            "") hwclock --systohc;;
        esac
        #rm_daemon hwclock
        ;;

Last edited by drrossum (2011-08-08 18:10:57)

Offline

#6 2011-08-08 20:21:30

drrossum
Member
From: Chicago
Registered: 2009-02-24
Posts: 82

Re: ntpd and syslog-ng boot sequence circular dependency

I just realized that the add_daemon and rm_daemon do not actually start anything but do only register the daemon in /run/daemons/.

So I guess the add_daemon and rm_daemon lines should better not be commented out.

It also means that the hwclock daemon already was intended to only adjust the hwclock at shutdown time, and it doesn't interfere in any way with ntp or other sysclock synchronizers. The daemon itself doesn't relate the two (hw clock and sys clock) in any way.

Anyway, mine does.

Offline

Board footer

Powered by FluxBB