Bug 9250 - xntpd should update the hardware clock upon shutdown
Summary: xntpd should update the hardware clock upon shutdown
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: xntp3
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
URL:
Whiteboard:
Keywords: FutureFeature
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-02-08 22:44 UTC by wingc
Modified: 2008-05-01 15:37 UTC (History)
0 users

(edit)
Clone Of:
(edit)
Last Closed: 2000-02-09 17:46:28 UTC


Attachments (Terms of Use)

Description wingc 2000-02-08 22:44:03 UTC
It would be nice to update the hardware clock on the machine when xntpd
shuts down. Many systems have incorrectly set hardware clocks and run
xntpd. The result is that syslog has nonsense time for log entries
immediately after startup, and then gets the correct time once xntpd
starts.

You could modify the init script for xntpd as follows:

--- xntpd.rc.orig	Tue Feb  8 17:42:23 2000
+++ xntpd.rc	Tue Feb  8 17:42:23 2000
@@ -35,6 +59,58 @@
         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xntpd
         ;;
   stop)
+	# save current system time to hardware clock, as time accuracy
+	# will only get worse from now on
+
+	# taken from rh6.1 /etc/rc.d/rc.sysinit
+	ARC=0
+	SRM=0
+	UTC=0
+
+
+	if [ -f /etc/sysconfig/clock ]; then
+	   . /etc/sysconfig/clock
+
+	   # convert old style clock config to new values
+	   if [ "${CLOCKMODE}" = "GMT" ]; then
+	      UTC=true
+	   elif [ "${CLOCKMODE}" = "ARC" ]; then
+	      ARC=true
+	   fi
+	fi
+
+	if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
+	   ARC=true
+	fi
+
+	CLOCKDEF=""
+	# write system time into hardware clock
+	CLOCKFLAGS="--systohc"
+
+	case "$UTC" in
+	   yes|true)
+	    CLOCKFLAGS="$CLOCKFLAGS -u";
+	    CLOCKDEF="$CLOCKDEF (utc)";
+	  ;;
+	esac
+
+	case "$ARC" in
+	     yes|true)
+	     	CLOCKFLAGS="$CLOCKFLAGS -A";
+	     	CLOCKDEF="$CLOCKDEF (arc)";
+	     ;;
+	esac
+	case "$SRM" in
+	     yes|true)
+		CLOCKFLAGS="$CLOCKFLAGS -S";
+		CLOCKDEF="$CLOCKDEF (srm)";
+	     ;;
+	esac
+
+	/sbin/hwclock $CLOCKFLAGS
+
+	action "Saving system time to hardware clock $CLOCKDEF: `date`" date
+
         # Stop daemons.
         echo -n "Shutting down xntpd: "
 	killproc xntpd



Thanks,

Chris Wing
wingc@engin.umich.edu

Comment 1 Jeff Johnson 2000-02-09 17:46:59 UTC
This is the Right Thing To Do. Unfortunately, we can't supply this in the
default configuration because of differences in the manner in which the
hardware clock is set on dual-booting machines. This purely support
issue is best dealt with by *not* trying to sync the system clock into
hardware.


Note You need to log in before you can comment on or make changes to this bug.