[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ancient date on TiBook (Was: Titanium trackpad blues)

On Thu, Apr 05, 2001 at 05:31:27PM -0500, Kevin van Haaren wrote:
> what about an init script that runs just after the network is up, but 
> before postgres, that checks the date and if it's < 2001 force it to 
> 1/1/2001 then run ntpdate to get the real date?

 I've got an x86 laptop that sets its date back to 1980 when I go to the
BIOS setup.  It's not a weak-battery problem, I know since I took it apart
and replaced the battery.  (hehe, it's pretty cool how all that stuff is
crammed into a laptop.:)  I mostly solved this problem by putting this near
the top of my system boot script:

hwclock --hctosys --utc
echo -n 'system clock: '

if [ $(date +%Y) -lt 2000 ]
   then echo "date is screwed, enter new one:"
   default="$(date -r /var/state/shutdown-time)"
   read -e -p "new date ($default): " newdate
   date -s "${newdate:=$default}"
   hwclock --systohc --utc &  # we don't need to wait for this.

 I think I was going to set up something to touch /var/state/shutdown-time,
but nothing does, so I guess I should use /var/log/messages.  (That stuff in
my boot script runs before syslogd (or anything else but console setup like
loadkeys, setterm, and fsck + remount / rw. ), so the date on
/var/log/messages won't get set by anything before I read it.

 (I have a custom boot script setup on my laptop because it is old and slow
and I don't like waiting for bash to grind its way through a whole pile of
work before I can do anything.  All my rcS.d stuff is in one file.)

#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@llama.nslug. , ns.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BCE

Reply to: