Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two computers, but I can´t change the time in one, so I have to sync one of this, with the other one. It has QNX. What can I do?? only commands

share|improve this question
1  
how about using ntp? –  MaQleod Apr 3 '13 at 18:39
    
@MaQleod the OP does not have root access to both machines so that is not an option. That's what I understood by "I can´t change the time in one". –  terdon Apr 3 '13 at 19:23

1 Answer 1

up vote 0 down vote accepted

The best solution would be to install NTP on both machines and have them sync to the same server. This is not an option, of course, if you only have root access to one of the two.

Assuming that you have ssh access to both machines, that machine1 is the one whose date you cannot change and machine2 the one whose date you can change (as the root user), you can do something like this:

remote_time=`ssh user@machine1 date` && date -s $remote_time

You will need to change user to your user name on machine1. If you run this command when logged in as root on machine2, you will set its date to the same value as machine1.

EXPLANATION:

The command above will ssh as the user user to machine1 and save the result of date (the current time and date for machine1) into the variable $remote_time. If the ssh exits successfully (&&), the second part of the command will set the time of machine2 (the machine the command was run from) to the value of $remote_time.

CAVEAT: The two commands take some time to complete. When I tested them on my machine, they took 0.3 seconds, it could take more on yours. Just be aware that if you need millisecond accuracy, this will not work. Then again, if you need millisecond accuracy, the only thing that will work is syncing both machines to an NTP server.

share|improve this answer
    
That's exactly what I was looking for, thanks. –  Evaristoyok Apr 7 '13 at 20:37

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.