in reply to Re: Daemon::Control pid-files
in thread Daemon::Control pid-files

Hi

thanks for replying.

As I explained in another post I wanted to use a sysv-init script so I can specify when to run it via LSB-entries.

Daemon::Control is handy has it can generate init-scripts but requires a pid-file even though I don't really need one, but the fact that it is not deleted does not really bother me.

And for my purposes it is quite enough to extract the time-information from the dvb-c signal and set the time once.

I also have ntpd running on my Pi (I don't quite understand how chrony could be easier as that was rather trivial) for those times when it is connected to the internet, but most of the time my pi is not.

Replies are listed 'Best First'.
Re^3: Daemon::Control pid-files
by haukex (Archbishop) on Apr 17, 2016 at 21:48 UTC

    Hi morgon,

    In that case I'd suggest to just write your own init script based on one of the templates I mentioned, or maybe the extensive /etc/init.d/skeleton if your system has it. Since an init script is just a shell script, you can do all your work there - in fact I even wrote an init script in Perl once - or you can write a simple init script whose start action simply runs the Perl script that sets the time. Since your task is just a one-off thing, you don't need all the complexities of a "real" init script, including Daemon::Control (for example you likely don't need the double-fork, PID file, etc.).

    My understanding is that ntpd works best for systems that are continually on the network, talking to multiple time servers, while chrony was designed with systems with intermittent or no internet access at all in mind. Telling ntpd which Internet NTP servers to sync to is easy; but I was having lots of trouble getting ntpd to sync to gpsd and a "Pulse Per Second" (PPS) signal, with chrony it was much easier to configure and it basically worked right away.

    Regards,
    -- Hauke D

      Yeah - Deamon::Control is overkill but as it generates the init-file it seems to be the fastest way (in terms of lazyness) to have a perl-subroutine run at boot-time.

      And thanks for mentioning chrony - never heard of it before but will have a look at it.

        Hi morgon,

        Looking back at what I wrote, it sounds like I'm very much against Daemon::Control, but my opinion is not that extreme - I've used the module myself and of course if it works, why not :-) And it sounds like you can just create the PID file in /tmp and ignore it afterwards.

        Just one more thought though: You mentioned in another reply that there are other init processes that depend on yours to set the time correctly. In that case, I'm not sure if forking into the background is good? Because I suspect init will only block until it's started the process, but not until it finishes, and if setting the time takes a few seconds, other processes may have been launched by init while the time hasn't been set yet. If that is indeed a problem then one solution might be to set Daemon::Control's fork option to zero.

        Regards,
        -- Hauke D