From 2de44ef544862f3ce9144a16c5158ed771fec6de Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Sun, 5 Jun 2011 19:39:49 +0200 Subject: hwclock: refactor daemon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: adjust and set time on boot, adjust rtc every hour, and on shutdown. Now: do not set time on boot, adjust rtc on shutdown. Rationale: 1) We can never ever set the systemtime after system is up and running, as this might make time go backwards (unless we are careful à la ntpd, but we don't want to get into that business). 2) We are under the assumption that exact time is not needed, we are just trying to avoid large, accumulating drifts over time. With the new (significantly simpler) implementation systemtime will be off by the drift since the last clean shutdown. With the old implementation systemtime would be off by the drift since last shutdown (even if it was unclean). Either way the drifts would not accumulate, and a clean reboot would get you a "perfect" time. Signed-off-by: Tom Gundersen --- hwclock | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'hwclock') diff --git a/hwclock b/hwclock index 117ab14..5996b95 100755 --- a/hwclock +++ b/hwclock @@ -11,27 +11,18 @@ esac case "$1" in start) - if [[ $HWCLOCK_PARAMS ]]; then - status "Adjusting Hardware Clock" \ - hwclock --adjust - stat_busy "Setting System Clock" - hwclock --hctosys $HWCLOCK_PARAMS || stat_die - stat_done - # Note: This also enables /etc/cron.hourly/adjtime - add_daemon hwclock - fi - ;; + add_daemon hwclock;; stop) - if [[ $HWCLOCK_PARAMS ]]; then - stat_busy "Saving System Clock" - hwclock --systohc $HWCLOCK_PARAMS || stat_die - stat_done - fi + case $HARDWARECLOCK in + UTC) hwclock --adjust --utc;; + localtime) hwclock --adjust --localtime;; + "") hwclock --adjust;; + esac rm_daemon hwclock ;; restart) $0 stop - sleep 1 + sleep 2 $0 start ;; *) -- cgit v1.2.3