I've noticed that some users are posting reply messages before the time they are actually posted. So I'd thought that I would help those chronology-challenged and post a simple script to help sync their clocks.

Note: ntp needs to be installed for this to work. I know this works on my SuSE, RH and Fedora systems. Put this script in your /etc/cron.daily/ and never have to worry about your computer's time being wrong again.

Consider this a Chrismas Hanukah, New Years present. There, my good deed is done for the year. Hope Santa notices.

Happy holidays everyone. :-D


[script] #!/bin/sh # # $Id: sync-clock,v 1.5 2003/02/04 20:23:39 jmates Exp $ # # Use ntpdate to get rough clock sync with the time server.

NTPDATE=/usr/sbin/ntpdate
SERVER=ntp.cpsc.ucalgary.ca
LOGFILE=/var/log/ntp-update

echo -n "Start -- " >> $LOGFILE
date >> $LOGFILE

# if running from cron (no tty available), sleep a bit to space
# out update requests to avoid slamming a server at a particular time
if ! test -t 0; then
 MYRAND=$RANDOM
 MYRAND=${MYRAND:=$$}

 if [ $MYRAND -gt 9 ]; then
   sleep `echo $MYRAND | sed 's/.*\(..\)$/\1/' | sed 's/^0//'`
 fi
fi

$NTPDATE -su $SERVER

# update hardware clock on Linux (RedHat?) systems
if [ -f /sbin/hwclock ]; then
 /sbin/hwclock --systohc
fi

echo -n "Done -- " >> $LOGFILE
date >> $LOGFILE
[/script]



--

Jason Louie BSc. CPSC
Web Applications Developer
Sorex Software Inc.
[EMAIL PROTECTED]



_______________________________________________
clug-talk mailing list
[EMAIL PROTECTED]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca

Reply via email to