Bug 9250 - xntpd should update the hardware clock upon shutdown
xntpd should update the hardware clock upon shutdown
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: xntp3 (Show other bugs)
6.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-02-08 17:44 EST by wingc
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-09 12:46:28 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description wingc 2000-02-08 17:44:03 EST
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 12:46:59 EST
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.