client server date sync

2011-01-12 Thread JNY

Hi,
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?

something like:
date 'cat datefile'

-- 
View this message in context: 
http://old.nabble.com/client-server-date-sync-tp30654251p30654251.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




Re: client server date sync

2011-01-12 Thread Bob Proulx
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