[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 04:43:46PM -0700, Jason E. Stewart wrote:
> "Kevin van Haaren" <kevin@vanhaaren.net> writes:
> > At 4:28 PM -0700 4/5/01, Jason E. Stewart 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?
> Hmmm... it might work. The issue is, I'm not sure if Pg is getting
> borked because:
> 1) it's seeing a date prior to epoch
> 2) it's seeing an out of order date...
> Your idea would work if 1) not if 2)

if combined with ntpdate it would work for either.  that requires
network connectivity however.

> Probably the Pg init script should just check the date and if it's
> wrong, refuse to start Pg with a big nasty error msg.

that would be rather easy, in the stop section of the initscript it
could save the current time, and then in the start section check that
the current time is greater then that saved:

	date +%s > /var/lib/postgres/lasttime

	if [ `date +%s` -lt `cat /var/lib/postgres/lasttime` ] ; then
		echo 1>&2 "WARNING: clock skew, not starting postgresql"
		exit 1

/var/lib/postgres may not be a safe place for that file, only root
should be able to write whereever the file is kept.  and this will
only work with GNU date since %s is a GNU extension, no problem for
debian but you can't use the same method on a BSD box.  

Ethan Benson

Attachment: pgpUVgEZuJzM1.pgp
Description: PGP signature

Reply to: