C-Keen has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

I need to synchronize my linux box with some time signal generating machine so that I have exact UTC on my system. Of course I'd like to realize this in perl. Any ideas?

Yours,

C-Keen

  • Comment on synchronization of system's time with perl?

Replies are listed 'Best First'.
Re: synchronization of system's time with perl?
by Beatnik (Parson) on Mar 20, 2001 at 13:49 UTC
    Try Net::Time, which is "time and daytime network client interface". Also check NTP Specs (RFC 1305)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: synchronization of system's time with perl?
by greenFox (Vicar) on Mar 20, 2001 at 13:45 UTC
    Well this isn't a perl answer but I am wondering why you wouldn't use NTP (network time protocol) which is designed to do exactly what you want to do...

    my $chainsaw = 'Perl';

rdate (synchronising server time with)
by grinder (Bishop) on Mar 20, 2001 at 14:14 UTC

    What's the point? rdate in a crontab is The Right Way to do it, or by going the full NTP route if you feel you really absolutely, positively have to.

    Just because TIMTOWTDI doesn't mean you should. Or do you have an extra special need for doing so that you didn't explicitly state?



    --
    g r i n d e r
Re: synchronization of system's time with perl?
by extremely (Priest) on Mar 21, 2001 at 02:07 UTC
    Perl isn't the right tool for this job, go find xntpd and use it. At the very least get ntpdate from the same package and stick it in your crontab.

    Doing NTP right for system timesync requires exacting maths and tight OS integration. Also, once you have xntpd running on your server, you can use it as a clean time source for all the other computers in your network. Dimension4 works great if you are stuck with M$PCs and need to timesync them to your Linux box.

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re: synchronization of system's time with perl?
by AgentM (Curate) on Mar 21, 2001 at 02:01 UTC
    Keep in mind that any home-grown solution would have to take several important steps to actually literally synchronize the clocks which the NTP and SNTP attempt to make amends with. "Lag" is a general term, but even in the case where the user doesn't "experience" lag, there is still some definitive amount of time for which the packets must travel through which is accessible through the TLI. Also, setting the clock after reading data takes some amount of time (hopefully less than a second!). It would be more beneficial if you learn how this is done and done correctly reading through a module source or program source (even in C) since this topic has been beaten into the ground.
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
Re: synchronization of system's time with perl?
by greenFox (Vicar) on Mar 21, 2001 at 07:23 UTC
    Coincidentally a friend called me up last night to look at his ppp dialer which was barfing, after I got ppp working he logged in and said "let me just run this script to fix up the time" and he had a perl script, nist.pl, for time synchronisation, you can find it here http://www.pages.drexel.edu/~aoc22/

    For the reasons AgentM and extremely have suggested in this thread its fitness for purpose is questionable but it does makes me wonder if there isn't an adage that says "if it can be done in Perl... it probably already has" :-)

    --
    my $chainsaw = 'Perl';