Previously I blogged about how to configure a Microsoft Windows Server as your NTP server for your networked environment. Today I would like to show you the steps to configure ubuntu PC to talk to your NTP server to make sure the time is always in-sync.
It is pretty straight forward with ubuntu. By default, ubuntu will talk to ubuntu NTP server (ntp.ubuntu.com) to adjust the time during the boot time. However, this is only a one time process during the boot time. For ubuntu servers that never get rebooted, or ubuntu client PCs only get reboot once a while (which is very common); checking network time during the boot time might not be sufficient enough. In today’s blog, I would like to show you how to configure your ubuntu box to check for the time once a day.
First, use the following command to make sure you can talk to your NTP server (ex. 22.214.171.124)
sudo ntpdate 126.96.36.199
If you get a reply then you are all good. Now you want to configure a cron job to check time once a day.
- go to cron.daily by entering “cd /etc/cron.daily”
- next create a new file by doing “sudo vi ntpdate”
- once you are in vi editor, you want to type “i” to insert a line
- then, type “ntpdate -s 188.8.131.52”
- once you are done, you want to save and exit. In vi editor, you do “ESC” key, and then type “:wq!” to write & quit
- now, change the file you just created with the correct permission with following command “sudo chmod 755 ntpdate”