0

Someone asked me to update the times on 4 servers that are not connected to the internet and they have no ntp server.

e.g

/etc/hosts 

146.92.25.3     jollibee  
146.92.25.4     mcdonalds  
146.92.25.5     burgerking  
146.92.25.6     chowking 

The easiest thing for me to do would be to run

date -s "25 Jul 2012 14:40:00"

for each of the 4 servers.

I know they will want me to do this again in the future and I find it a pain to set the time manually. What i want to do is set the time on one box and then set the times on the other boxes off this box.

e.g. if i set jollibee's time to the correct date i would then run

[root@mcdonalds /]# date -s `ssh jollibee 'date +"%d %b %Y %T"'`

and so on for my other servers

Thing is I'm getting:

date: too many non-option arguments: 2012 ...
Try `date --help' for more information.

Can anyone tell me what I'm doing wrong here?

2 Answers 2

1

The best solution is to setup NTP servers on all the four servers with each other configured as upstreams (but no upstreams on the Internet). You probably want to give one of the servers a higher stratum so that the others all tend to synchronise to that one.

Another option is to setup rdate. Configure one of the servers to run a Time Protocol server (typically done with inetd), and setup a cronjob on the other servers to run rdate regularly against the time server.

1
  • If it was up to me i would set that up but unfortunately it will take time to do that.
    – rumz
    Jul 25, 2012 at 7:04
2

I am not sure whether this is a good way to set the date/time of your server or not, but you need to modify your command by enclosing the ssh command within quotes such as:

date -s "`ssh jollibee 'date +"%d %b %Y %T"'`"
2
  • Thanks i didn't know it was that simple!
    – rumz
    Jul 25, 2012 at 7:03
  • It is only for this one instance, for other servers we have NTP setup.
    – rumz
    Jul 25, 2012 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .