How can I permanently fix my clock synchronization problem?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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?
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.