aboutsummaryrefslogtreecommitdiff
path: root/hwclock
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2011-06-05 19:39:49 +0200
committerTom Gundersen <teg@jklm.no>2011-06-05 19:39:49 +0200
commit2de44ef544862f3ce9144a16c5158ed771fec6de (patch)
treee47f51d5b4e8260f99c2386734f856045641a54c /hwclock
parent3b1d78bc524724ed49ac000d85f477876ccfc794 (diff)
downloadinitscripts-2de44ef544862f3ce9144a16c5158ed771fec6de.tar.xz
hwclock: refactor daemon
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 <teg@jklm.no>
Diffstat (limited to 'hwclock')
-rwxr-xr-xhwclock23
1 files changed, 7 insertions, 16 deletions
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
;;
*)