SEARCH

BYTE SIZE TIPS / QUICK, HELPFUL TIPS

How-To Geek

How to Sync Your Linux Server Time with Network Time Servers (NTP)

image

Most servers are probably automatically configured to network time, but if you want to set it up for yourself, or want to change the servers that you are syncing to, here’s the quick article that shows you how to do it.

Since I had to do this earlier today, I decided it would make a lot of sense to write it down for the next time that I need to do it. Yeah, this article is really just for me.

First, you’ll need to install NTP if it isn’t already installed. For Debian or Ubuntu, that would be this command:

sudo apt-get install ntp

For Redhat or CentOS, you’ll need to use this one:

yum install ntp

Then you’ll want to edit the /etc/ntp.conf file, which is quite possibly already filled out for you.

vi /etc/ntp.conf

You’ll find a lot of lines in there, but the important ones are the server lines. You can get a list of server addresses at www.pool.ntp.org, find the preferred ones for your area, and then add them to the file. For my purposes, that meant:

server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org

Then you’ll need to restart or start the NTPD service:

/etc/init.d/ntpd restart

If you want to update the time right now, you can stop the NTP service and then run the following command, swapping out your preferred server for pool.ntp.org.

/usr/sbin/ntpdate pool.ntp.org

Fairly simple.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 03/31/13

RECOMMENDED POSTS

Enter Your Email Here to Get Access for Free:

Go check your email!