time syncronization

time syncronization

Post by Jim Pazaren » Fri, 06 Sep 1996 04:00:00



Is there a program available to allow one system to phone another,
poll the date & time, and set itself? The machines are not on the net
therefore I can't use the neat tricks available in that respect.

I don't want to phone the Greenich time base, but just one local system
who will be the 'master' time in a group of 5 remote systems.

I was thinking along the lines of using the "/usr/lib/uucp/Systems" file
for a login script, and phoning a system which simply spits out the date and
hangs up.

I imagine I could write a utility to accomplish this, but I was hoping
to avoid it.

Any ideas would be appreciated.

================================================================================
  Jim Pazarena                    phone: (604) 559-4444
  Box 550 - 405 2nd Avenue          fax: (604) 559-8404

  CANADA   V0T 1S0                business name: qcislands net

 
 
 

time syncronization

Post by Jean-Pierre Radl » Fri, 06 Sep 1996 04:00:00


Quote:Jim Pazarena writes:
> Is there a program available to allow one system to phone another,
> poll the date & time, and set itself? The machines are not on the net
> therefore I can't use the neat tricks available in that respect.

> I don't want to phone the Greenich time base, but just one local system
> who will be the 'master' time in a group of 5 remote systems.

> I was thinking along the lines of using the "/usr/lib/uucp/Systems" file
> for a login script, and phoning a system which simply spits out the date and
> hangs up.

I've done this using xc with this script:

#.utc   set the system time to the US Naval Observatory's
        set cis off
        tty "off"

        if ! linked; then
                transmit "ATs0=0s111=0^M"
                dial "12026530351"
        endif

        while ! waitfor "CONNECT" 60
        do
                redial
        done

        pipe "utc -s"
        quit

Now if you don't want to call Greenwich or the Naval Obersvatory, but
simply another computer, just have the master computer emit the same
format as the Observatory, described in the source code for utc:

/*
 * The Naval Observatory clock (+1 202 653 0351) prints this every second:
 *
 *      *
 *      jjjjj ddd hhmmss UTC
 *
 * jjjjj        Julian date modulo 2400000
 * ddd          days since beginning of year
 * hhmmss       time of day in Universal Time Coordinated
 */

#include <stdio.h>
#include <time.h>
#include <sys/types.h>

#define EPOCH           40587                   /* UNIX starts JD 2440587, */
#define leap(y, m)      ((y+m-1 - 70%m) / m)    /* also known as 1/1/70 */
#define TONE            '*'
#define TIME            "\n%05ld %03d %02d%02d%02d UTC"

main(argc, argv)
int     argc;
char    *argv[];
{
        int     setflg = 0, prtflg = 0;
        int     y, d, h, m, s;
        long    j;
        time_t  now;
        int     c;

        while ((c = getopt(argc, argv, "sp")) != EOF)
                switch (c) {
                case 's': setflg++; break;
                case 'p': prtflg++; break;
                default:
                        fprintf(stderr, "usage: %s [-s] [-p]\n", argv[0]);
                        return 1;
                }
        if (setflg || prtflg) {
                while ((c = getchar()) != TONE)
                        if (c == EOF)
                                return 1;
                if (scanf(TIME, &j, &d, &h, &m, &s) != 5)
                        return 1;
                now = (((j - EPOCH) * 24 + h) * 60 + m) * 60 + s;
                if (setflg && stime(&now) == -1)
                        perror(argv[0]);
                if (prtflg)
                        fputs(ctime(&now), stdout);
        } else {
                for (c = 0; c < 60; c++) {
                        time(&now);
                        s = (now % 60);
                        m = (now /= 60) % 60;
                        h = (now /= 60) % 24;
                        d = (now /= 24) % 365;
                        j = now + EPOCH;
                        y = (now /= 365);
                        d += 1 - leap(y, 4) + leap(y, 100) - leap(y, 400);
                        putchar(TONE);
                        printf(TIME, j, d, h, m, s);
                        putchar('\n');
                        fflush(stdout);
                        sleep(1);
                }
        }
        return 0;

Quote:}

--


 
 
 

1. Time syncronization - How ?

Visit the NTP page at:

http://www.eecis.udel.edu/~ntp/

If you are running Red Hat, ntp is usually supplied as an RPM package on
the CD.

               Al

--
Al Jarvi
Computer Specialist (Systems Analyst)
NOAA, National Weather Service
CRS Program Office

2. Increasing number of open files?

3. time syncronization daemon for Solaris ?

4. newbie need help!

5. time syncronization

6. Linux PDA

7. Howto: time syncronization

8. Adaptec 29160 Controller

9. How to do Time Syncronization in Unix Sys.

10. convert UT time in local time / local time in UT time

11. time time time how can I tell the time

12. File syncronization in Linux

13. Apache 1.3.23 syncronization problem