From 5292c03dde57902d170a3a7bbd3a74e6ae1acdf9 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Mon, 21 Jan 2013 17:53:36 +0100 Subject: [PATCH] setclock: use last log access time if no rtc found. This prevents time backjumps that destroy graphs and vnstat data. --- src/initscripts/init.d/setclock | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/initscripts/init.d/setclock b/src/initscripts/init.d/setclock index 6083108dd7..86c161453b 100644 --- a/src/initscripts/init.d/setclock +++ b/src/initscripts/init.d/setclock @@ -24,10 +24,21 @@ case ${1} in # udev not create the rtc symlink if rtc is in the kernel if [ ! -e /dev/rtc ]; then - ln -s rtc0 /dev/rtc + if [ -e /dev/rtc0 ]; then + ln -s rtc0 /dev/rtc + fi fi hwclock --hctosys ${CLOCKPARAMS} &>/dev/null + if [ ! ${?} == 0 ]; then + if [ ! -z /var/log/messages ]; then + boot_mesg -n "No RTC found, set time to last log accesstime ... " + DATE=`stat --format "%y" /var/log/messages | cut -d" " -f1` + TIME=`stat --format "%y" /var/log/messages | sed -e "s|\..*||g" | cut -d" " -f2` + date -s $DATE > /dev/null + date -s $TIME + fi + fi evaluate_retval ;; -- 2.39.5