Bug 9250

Summary: xntpd should update the hardware clock upon shutdown
Product: [Retired] Red Hat Linux Reporter: wingc
Component: xntp3Assignee: Jeff Johnson <jbj>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1Keywords: FutureFeature
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-02-09 17:46:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.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.