A web page with a shell script fron end to be run by cron, assuming a uucp connection with other machines whose clocks are to be synchronized with a central machine. There are three files, internally documented, two of which are C programs that need to be compiled.
This is useful with a system of local machines that are set up with uucp connection, so tht only the master machine needs to have its clock set; synchrosys propagates the the time setting to the other machines. My experience has been that the synchronization cab be had to within less than five seconds.
: # synchrosys # # Synchronize the clock of a named remote slave system with the current # system clock. # # Cf. /etc/etime, /etc/ssyndemon (other parts of this synchronizing system) # if [ $# -eq 0 ]; then echo "synchrosys: remote system name argument missing" exit 1 fi if [ $# -gt 1 ]; then echo "synchrosys: too many remote system names" exit 1 fi # # # NB As point of secure operation we should hold up here in a loop until # the disappearance of a lockfile in /usr/spool/uucp. # # Estimate of how long it will take to activate uux, call another system, # login and secure a uux execution of the daemon 'ssyndemon'. # ADVANCE_SECS=50 # NB 777 on TDIR and path to it must be maintained. TDIR=/usr/tmp TFILE=ssyndf DAEMON=/etc/ssyndemon # # # Note: # It Appears that (local trantor=systemid system) loses about 2 mins per week. # # # Form the argument to be picked up by the daemon on the remote system # SETTIME=`/etc/etime $ADVANCE_SECS` cd $TDIR echo "$SETTIME\c" > $TFILE chmog 666 uucp root $TFILE uuq -s -P $1 $TFILE # # Execute Remote System Clock Synchronization Daemon uux -z $1!$DAEMON sleep $ADVANCE_SECS # Remove the local time file rm $TFILE exit 0 ------------------------------------------------------------------------- /* etime.c * * */ #include#include long time(); int main( argc, argv ) int argc; char *argv[]; { long et, at; if( argc != 2 ) { fprintf( stderr, "%s: missing argument.\n", argv[ 0 ] ); exit( 1 ); } if( sscanf( argv[ 1 ], "%ld", &at ) != 1 ) { fprintf( stderr, "%s: can't read numerical argument.\n", argv[ 0 ] ); exit( 1 ); } et = time( (long *)0 ); printf( "%ld", (et + at) ); exit( 0 ); return( 0 ); } /* End main() */ ------------------------------------------------------------------------ /* ssyndemon.c * * A daemon that periodically looks for arriving file that contains * the setting for the system clock. * The demon only needs to be active when such an activity is scheduled. * The remote system might be able to activate the demon before putting * the file in place. Once the demon sets the clock, he should exit until * invoked once again. * * Wakes up every minute. * */ #include #include #include #include #include #define TIMEFILE "/usr/tmp/ssyndf" #define CYCLE 5 int main( argc, argv ) int argc; char *argv[]; { int stime(); FILE *fptr; long elapsed; if( signal( SIGINT, SIG_IGN ) != SIG_IGN ) signal( SIGINT, SIG_IGN ); if( signal( SIGKILL, SIG_IGN ) != SIG_IGN ) signal( SIGKILL, SIG_IGN ); if( fork() == 0 ) { /* Fork a child process, sending the daemon into the * loop background. */ fclose( stdin ); fclose( stdout ); while( 1 ) { /* Check for the existence of the time file */ if( access( TIMEFILE, 0 ) == 0 ) { fptr = fopen( TIMEFILE, "r" ); fscanf( fptr, "%ld", &elapsed ); if( unlink( TIMEFILE ) < 0 ) { fprintf( stderr, "%s: can't unlink %s\n", argv[0], TIMEFILE ); exit( 1 ); } if( stime( &elapsed ) < 0 ) { fprintf( stderr, "%s: can't set system time\n", argv[0] ); exit( 1 ); } exit( 0 ); } /* Otherwise continue waiting */ /* Wake up and look every CYCLE */ sleep( CYCLE ); } } else { /* Exit parent process */ if( signal( SIGINT, SIG_DFL ) != SIG_DFL ) signal( SIGINT, SIG_DFL ); if( signal( SIGKILL, SIG_DFL ) != SIG_DFL ) signal( SIGKILL, SIG_DFL ); exit( 0 ); } /* End if( fork() ) */ exit( 0 ); return( 0 ); } /* End main() */