Configure NTP in ubuntu

By July 29, 2011 February 18th, 2015 IT Stuffs

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. 192.1.1.1)

sudo ntpdate 192.1.1.1

If you get a reply then you are all good. Now you want to configure a cron job to check time once a day.

  1. go to cron.daily by entering “cd /etc/cron.daily”
  2. next create a new file by doing “sudo vi ntpdate”
  3. once you are in vi editor, you want to type “i” to insert a line
  4. then, type “ntpdate -s 192.1.1.1”
  5. once you are done, you want to save and exit. In vi editor, you do “ESC” key, and then type “:wq!” to write & quit
  6. now, change the file you just created with the correct permission with following command “sudo chmod 755 ntpdate”
That’s it. Now your ubuntu box should always have the correct time.

Leave a Reply