bug-bash
[Top][All Lists]
Advanced

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

Re: client server date sync


From: Bob Proulx
Subject: Re: client server date sync
Date: Wed, 12 Jan 2011 11:38:23 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

JNY wrote:
> I do not have access to NTP.
> I have a script which will write the date of my server to a file and scp it
> to my clients.  Is there a way to use the contents of this file to update
> the date of the clients?

I hesitate to help you with this issue since stepping the clock as you
propose is quite bad and has the potential for many problems.
Sometimes programs (think cron) will see multiple times again.
Sometimes they will not see a time at all.  It is a problem.

> something like:
> date 'cat datefile'

Because I can't stop myself from helping anyway I will note that GNU
date has the --set=STRING option that allows you to set the time from
a date string.  If you can ssh (since you mentioned scp) then you can
set the time using the string.  Use an unambiguous format such as that
provided by date -R.

Pull:
  date --date="$(ssh remoteserverhost date -R)"

Push:
  date -R | ssh remoteclienthost date --date='"$(cat)"'

The --date= just prints the time.  After you are happy with the
results change --date= to --set= which actually sets the system clock.

I think it would be much more productive use of your resources to
enable ntp instead.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]