LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-25-2010, 07:25 AM   #1
gr33d
Member
 
Registered: Dec 2008
Posts: 41

Rep: Reputation: 15
How can I permanently fix my clock synchronization problem?


Ubuntu 7.10 server i386 clock/date/time won't stay in sync. Are their log files I can view to tell when the clock changes? For a temporary fix, I created a file in /etc/cron.hourly:

#!/bin/sh
ntpdate time.nist.gov

However, this still leaves a potential hour of unchecked time. Is there a cron.minutely? That would still leave a potential minute of unchecked time. I have read about CMOS battery problems, but what if this does not fix it? I'd like to be able to troubleshoot this as a completely software problem.

My squid logs are showing dates back in 2005 when the clock changes, and my time-sensitive access controls are skewed and end up allowing users to surf prohibited websites during business hours.

Thanks in advance!
 
Old 03-25-2010, 07:39 AM   #2
nuwen52
Member
 
Registered: Feb 2009
Distribution: CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 205

Rep: Reputation: 46
Try running an ntp server. It will keep your own clocked sync'd and you can set it to not serve any other computers. It can account for drift rates in your system clock by adjusting it's own update times and driftrate calculations. Also, the newer versions are fairly easy to configure.
 
Old 03-25-2010, 07:41 AM   #3
gr33d
Member
 
Registered: Dec 2008
Posts: 41

Original Poster
Rep: Reputation: 15
that sounds like a good idea. ill read up and let you know
 
Old 03-25-2010, 07:46 AM   #4
nuwen52
Member
 
Registered: Feb 2009
Distribution: CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 205

Rep: Reputation: 46
Something I did forget to mention. If it's on a server which reboots often and may loose time in the time it's off, you can use ntpdate on boot to do the initial sync before starting the ntpd. This is a good idea since ntpd doesn't like to sync up if the time is too different from what it should be.

I do this on my home servers.
 
Old 03-25-2010, 07:48 AM   #5
gr33d
Member
 
Registered: Dec 2008
Posts: 41

Original Poster
Rep: Reputation: 15
this server is only reboot under extreme troubleshooting circumstances. thats why i was hoping to avoid the cmos battery since that has to be done when powered off, correct?

how can i run commands on boot?
 
Old 03-25-2010, 07:50 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by gr33d View Post
I have read about CMOS battery problems, but what if this does not fix it?
The CMOS battery is only used to keep the clock going when the system is powered down. While the system is running Linux keeps its own time (presumably in a hardware device). Boot and shutdown messages confirm this when they say something like "Setting time from hardware clock" and "Saving time to hardware clock"

If your time is changing while the system is running (more than a slight drift) then you either have a hardware problem or something is changing it.
 
Old 03-25-2010, 07:53 AM   #7
sreeharsha.t
Member
 
Registered: Jan 2009
Location: Mumbai, India
Distribution: Fedora 9, 10,11, RHEL 5
Posts: 67

Rep: Reputation: 18
Quote:
Originally Posted by gr33d View Post
how can i run commands on boot?
You have to modify the system initializing scripts. To run ntpdate before running the ntpd. Change the file (/etc/init.d/ntpd probably) to include a line to run ntpdate just before ntpd is acutally run.
 
Old 03-25-2010, 07:55 AM   #8
nuwen52
Member
 
Registered: Feb 2009
Distribution: CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 205

Rep: Reputation: 46
Quote:
how can i run commands on boot?
This depends on the system that you run. There are a few different ways to run commands on boot. On redhat based systems, you could add a script into the /etc/rc.d/init.d/scripts and then call it from the various runtime directories. Gentoo is different from that. Ubuntu, I don't know, but that question can probably be easily searched from google or on the boards here.
 
Old 03-25-2010, 07:58 AM   #9
sreeharsha.t
Member
 
Registered: Jan 2009
Location: Mumbai, India
Distribution: Fedora 9, 10,11, RHEL 5
Posts: 67

Rep: Reputation: 18
Ubuntu uses Upstream startup scripts which are slightly different from the Sys V Init Scripts.
 
Old 03-25-2010, 08:14 AM   #10
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by nuwen52 View Post
Ubuntu, I don't know, but that question can probably be easily searched from google or on the boards here.
On ubuntu 8.04 I had to install the ntp package (done via Synaptic) then used System->Admin->"Time + Date" to set time zone and enter time server names. Time server names are best chosen from the country lists at http://www.pool.ntp.org/en/use.html (or continent if you live in a country with inadequate time servers).

This didn't seem to work, though; inspecting /etc/ntp.conf showed ntp.ubuntu.com had gone but the new ones had not appeared.

After adding the missing servers manually to the end of /etc/ntp.conf like this
Code:
server in.pool.ntp.org
server asia.pool.ntp.org
and rebooting (not the fastest way but works and is easy) /var/log/daemon.log showed ntpdate and ntpd activity. It can take several minutes for ntpd to synchronise -- hey, it's got the time!

AFAIK NTP is started by the /etc/init.d/networking script and you don't need to do anything after installing and configuring it to have it stated at boot.
 
Old 03-25-2010, 08:17 AM   #11
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by sreeharsha.t View Post
Ubuntu uses Upstream startup scripts which are slightly different from the Sys V Init Scripts.
Do you mean Upstart? The SysVinit mechanism was still in use, parallel to the few bits of Upstart in 8.04; I imagine there was less Upstart in 7.10.
 
Old 03-29-2010, 02:06 PM   #12
gr33d
Member
 
Registered: Dec 2008
Posts: 41

Original Poster
Rep: Reputation: 15
the ntp server seems to be doing the trick. thanks for your help!
 
  


Reply

Tags
cron, linux, synchronization, time, ubuntuserver


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Clock Synchronization in a Distributed System manolakis Programming 5 02-03-2009 09:33 AM
hardware-clock synchronization fariborz Programming 3 05-02-2008 07:54 AM
clock synchronization rasejo Linux - General 12 07-12-2007 06:53 PM
tryhing to fix my system clock time slinky2004 Linux - General 6 10-06-2005 06:43 PM
need to fix system clock on slackware 10.0 salviadud Slackware 3 03-02-2005 01:50 PM


All times are GMT -5. The time now is 11:13 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration