#!/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 <ccollins@pharmacore.com> #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

In reply to TimeSet.pl by PearlJamned

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.