Debian Admin - Your way to Debian World

January 26, 2007

Keeping your System clock current, automatically via Network Time Protocol (NTP)

by @ 10:13 am. Filed under General, Network, Other Linux

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

NTP, the Network Time Protocol, is used to keep computer clocks accurate over the Internet, or by following an accurate hardware receiver which interprets GPS, DCF-77, NIST or similar time signals.

ntpdate is a simple NTP client which allows a system’s clock to be set to match the time obtained by communicating with one or more servers.

ntpdate is optional (but recommended) if you’re running an NTP server, because initially setting the system clock to an almost-correct time will help the NTP server synchronize faster.

The ntpdate client by itself is useful for occasionally setting the time on machines that are not on the net full-time, such as laptops.

Install ntp client in Debian

#apt-get install ntpdate

Install ntp client in Ubuntu

sudo apt-get install ntpdate

ntpdate will automatically run while bboting your system. Ubuntu stores script at /etc/network/if-up.d/ntpdate location.

If you wish to just run script again just type command

sudo /etc/network/if-up.d/ntpdate

sudo ntpdate pool.ntp.org

If you want to use you own ntp servers you need to edit the /etc/default/ntpdate file using the following command

sudo vi /etc/default/ntpdate

File looks like below

# servers to check. (Separate multiple servers with spaces.)
NTPSERVERS=”0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org”
#
# additional options for ntpdate
#NTPOPTIONS=”-v”
NTPOPTIONS=”-u”
NTPSERVERS=”ntp.ubuntu.com”

If you wan to use your own NTP server enter the list of NTP servers under NTPSERVERS

To avoid stepping the clock you must run ntpdate every 1 or 2 hours using cronjob

crontab -e

#Setup NTPDATE

@hourly /etc/network/if-up.d/ntpdate

Save and close the file.

You can also use the following script to run every hour from your cronjob

#!/bin/bash

/usr/sbin/ntpdate -s

/sbin/hwclock --adjust

/sbin/hwclock --systohc

Tags: , , , , , , , , , ,

You may also be interested in...

Leave a Reply

Subscribe RSS Feed

subscribe to the Debian Admin RSS feed

Internal links:

Sponsors:



Categories:

Support Debian Admin

Amount $:
Website(Optional):

Sponsors:

Archives:

WidgetBucks - Trend Watch - WidgetBucks.com

Related Links:


WidgetBucks - Trend Watch - WidgetBucks.com

Favourite Sites:

Wordpress Collection
Windows Reference
Ubuntu Geek
DebianHelp
All About Debian Tutorials
Power Electrical
Check Your IP Here
Debian,Ubuntu News
DebCentral
Tuxmachines
Capnkirby
Libervis
Nuxifield
Linux Horizon
Linux Appfinder
Debuntu
GNU/Linux For Everyone
Free Penguin
DebianAdmin is not related to the Debian Project.
This site is copyright © 2006,2007 Debian Admin
All Trademarks are the property of their respective owners.
The contents of this website may not be mirrored or archived without the express written permission of DebianAdmin Site Owner.

DISCLAIMER: All the information, troubleshooting methods, utilities offered in this website is provided AS-IS, without any warranties. Though I strive for perfection, and always test the validity and effectiveness of the troubleshooting content in various systems, I assume no responsibility for your use of these Fixes, Utilities and other troubleshooting advice. The author will not be liable for any special, incidental, consequential or indirect damages due to loss of data or any other reason. All use is completely at your own risk. Changes to the existing content and new additions are made to this website periodically, without notification.
Rodney's Kontera DynamiContext Plugin plugged in.