#!/usr/bin/perl ########################################### # Mike Schilli, 2003 (m@perlmeister.com) ########################################### use warnings; use strict; use IO::Socket::INET; our $CVSVERSION = '$Revision: 1.3 $'; my $HWCLOCK_CMD = "/sbin/hwclock"; my $DATE_CMD = "/bin/date"; my $s; $s = IO::Socket::INET->new('www.time.gov:daytime') or die "Cannot create socket: $@"; my $result = join '', <$s>; if($result =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/) { system("$HWCLOCK_CMD --set --utc --date='$3/$2/$1 $4:$5:$6'") and die "hwclock failed"; system("$DATE_CMD --utc $2$3$4$5$1.$6"); } __END__ =head1 NAME synctime - Sync a Linux system's time with the official time =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS synctime =head1 DESCRIPTION B contacts the time server www.time.gov on port 13 to obtain the official UTC time and then uses it to call the commands C and from the command line. =head1 LEGALESE Copyright 2003 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2003, Mike Schilli =cut 03-06-22 23:39:56 hwclock --set --date="9/22/96 16:45:05" date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]