#!/usr/bin/perl # #timeset.pl ver2.0 final # #A simple enough, yet effecient perl script which #uses a list defined as @serverlist to set a *nix #system's time...also added for loop which verifies #the time server so that dead servers are bypassed #if none of these servers work chk yo connection ;) #PLEASE - gimme some feedback...thx # ################################################ #Charlie Collins (ccollins@pharmacore.com) # #warning: beware of the penguin...AWK! # #perlmonks.org -=PearlJamned=- # #yadda, yadda, yadda # #hope this helps someone # #I'm a perl newB so lemme know what I coulda # #done better, plz # ################################################ $synchlists = "rdate -s"; @synchtimeh = ("hwclock", "--hctosys"); @synchtimei = ("hwclock", "--systohc"); @serverlist = ("time.nist.gov", "ntp.cmr.gov", "tock.usno.navy.mil", "tick.usno.navy.mil", "time.twc.weather.com", "tick.mit.edu", "ntp.colby.edu"); $list = @serverlist; for ($count = 1; $count <= $list;) { $ping = @serverlist[$count-1]; @number[$count-1] = `ping -q -c 1 $ping`; print "$count: \n" ; print "@number[count-1] \n"; if (@number[$count-1] eq "") { print "\n$ping was not found\n"; $count++ } else { $count = $list+1; #breaks loop } } @synchtimes = ($synchlists, $ping); system(@synchtimes); system(@synchtimei); system(@synchtimeh); #feedback please #the time server I've chosen to use (unless it dies) #time.nist.gov #hwclock --systohc --hctosys #rdate -s time.nist.gov #serverlist from http://www.eecis.udel.edu/~mills/ntp/servers.htm #other info http://www.bgw.org/tutorials/operating_systems/linux/set_c ock.php3