Setup NTP service on Ubuntu

Having the correct time on your server is really important especially if you are looking at log files. There is nothing worse than knowing the time something went wrong but not finding it in the log file.

The simple way to solve the problem is to install an NTP service so that the time and date is checked and corrected on a regular basis.

Setup

The first thing to check is the current date and time on the server.

The date command will give you this.

> date

You can then check that the time is correct. If it is it maybe that the NTP service is already working.

Type

ps aux | grep ntp

If it is not installed type

sudo apt-get install ntp

Unfortuanatly installing the service does not change the time straight away. To Force a refresh type

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start

Your servers should now give the correct time.