# How can a raspberry pi get time from another pi

I'm trying to set a slave pi to let get time from master pi using ntp service. The master pi has been set to be a hotspot (which is not connected to the internet) and the slave pi connect to it via wifi. The master pi has its own time and it is an ntp server. Now I can use windows to synchronize the time from the master pi, but when it comes to the slave pi, it doesn't work as I expect, the ntp.conf must have something wrong. So how could I configure the ntp.conf file to let the slave pi get the time from the master pi?

Updated: I added a line "server 192.168.42.1 prefer" (which is the master pi's IP address) in the ntp.conf, and add # to the line "server 0 debian.pool.ntp.org ibrust" in the slave pi. Then every time slave pi is rebooted, it synchronized, with the master pi's. But if I set another time (like sudo date -s 2016/2/2) in the slave pi after it is rebooted, the time of the slave pi will not synchronize with the master one, and it will keep the time I set. What should I configure to make sure that the slave pi will synchronize with the master pi once in a while, and correct its time? Thanks!

• May be better to ask on ServerFault. As for the question: What's in your ntp.conf and what have you tried? – kba Feb 20 '16 at 14:09
• The problems have solved, it turns out the ntp does not responsible for synchronize time, and ntpdate responsible for that. So if I use "ntpdate 192.168.42.1" in terminal, the time will be synchronized. – kurt wang Feb 20 '16 at 17:20
• Is there any reason why you want to do this? – EDP Feb 20 '16 at 17:30
• @kurt wang I wrote that like 3 hours earlier in answer. – Flash Thunder Feb 20 '16 at 18:12
• @FlashThunder Yes, I got the problem solved according to your answer, without your answer I would not think of the "ntpdate" issue, thanks! – kurt wang Feb 21 '16 at 6:41

apt-get install ntp <-- server
apt-get install ntpdate <-- client