Call: (480) 382-8464

How to Setup NTP on ubuntu

Want to have your server sync to a public time clock so it can keep accurate time? Here is how it’s done:

First, you need to make sure you have the time zone setup as you like. I set all of my servers to my timezone, regardless of where the server actually is. This makes finding information in logs easier. Many people specify UTC or GMT time. This is a considered best practice, especially for enterprise level servers. Most of our customers are smaller and have only 1 or 2 regions, so we will use our time zone (because we troubleshoot their issues and it makes it easier on us).

Specify Time Zone


(1:99)# dpkg-reconfigure tzdata

Current default time zone: 'America/Chicago'
Local time is now:      Thu Feb  5 04:30:44 CST 2015.
Universal Time is now:  Thu Feb  5 10:30:44 UTC 2015.

tzdata

Set Approximate Initial Time


(1:99)# /bin/date MMDDHHMMCCYY
(1:99)# /bin/date 020504312015
Thu Feb  5 04:31:00 CST 2015

Update the NTP pool

We add 3 NTP servers to the pool so it can check more reliably


(1:101)# ntpdate 0.north-america.pool.ntp.org
 5 Feb 04:35:34 ntpdate[2890]: adjust time server 132.163.4.102 offset 62.967271 sec

(1:101)# ntpdate 1.north-america.pool.ntp.org
 5 Feb 04:36:18 ntpdate[2897]: adjust time server 74.207.242.71 offset -0.004201 sec

(1:102)# ntpdate 2.north-america.pool.ntp.org
 5 Feb 04:36:59 ntpdate[2903]: adjust time server 199.182.221.110 offset 0.001515 sec

Update System Clock

This doesn’t work on a virtual machine or VPS, but on a standalone, it does:


hwclock --systohc --utc

Verify NTP is working

You can install the ntp client, though this isn’t required:


(1:106)# apt-get install ntp

(1:106)# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 time-c.nist.gov .ACTS.           1 u    3   64    1   73.392   -2.196   0.000
 wotan.tuxli.ch  91.189.89.199    3 u    2   64    1  162.693   -1.093   0.000
 lyla.preshweb.c 129.215.160.240  3 u    1   64    1  161.516    1.594   0.000
 a1.pcloud.com   200.98.196.212   2 u    -   64    1   54.421   -1.160   0.000
 golem.canonical .INIT.          16 u    -   64    0    0.000    0.000   0.000

Or you can simply look at your syslogs:


(1:108)# cat /var/log/syslog | grep ntp

ntpsyslog

Reboot

Services will need to update logs with the new time, and the most reliable way to do this is to reboot the server.

Leave a Reply

Your email address will not be published. Required fields are marked *

Main Offers/Services

Hosting and website related services offered by Digital Crunch:



Managed VPS Hosting

Server Updates, Module/Software Installs, Firewall, Security, Hosting Management, Wordpress - let us manage it for you

Hosted Email

Setup and Maintain Business Class, Secure Email Hosting including spam protection and 25GB of storage space

Linux Consulting

Server Updates, Module/Software Installs, Firewall, Security, Hosting, Wordpress and Apps, anything related to Linux

Email Marketing Services

We broadcast your content to your list, capture leads for you, follow up on schedules, make more sales for you

Website Maintenance

Content updates, menu changes, graphics changes, adding content, getting links, building traffic, building sales funnels

Hosting Tutorials

Tutorials we've written for other customers that like to get their hands dirty and learn about hosting