Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
If it was up to me i would set that up but unfortunately it will take time to do that. –  rumz Jul 25 '12 at 7:04

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"'`"
share|improve this answer
    
Thanks i didn't know it was that simple! –  rumz Jul 25 '12 at 7:03
    
It is only for this one instance, for other servers we have NTP setup. –  rumz Jul 25 '12 at 7:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.