Thursday, September 12, 2013

Solve CMOS Battery Issues with NTP

A Hewlett-Packard Mini 1000 netbook computer, ...
Hewlett-Packard Mini 1000 netbook Photo credit: Wikipedia)
I guess it was time. My HP Mini 1000 netbook was giving me the wrong time and date every time it booted up. It made going to websites with HTTPS impossible because I was apparently accessing them from the past. Resetting the time didn't work because it would forget the current time and reset back to 2002. I would then manually reset the time using ntpdate.
After a few times, I got tired of this and decided that there is a better way. Since the netbook is connected to the Internet most of the time, I knew that a script could be triggered to run every time the network card started up. All I needed to do was to add the ntpdate command and options to it. Problem was I didn't know what script it was. I wasn't also big on making a custom change that would affect future updates.
I knew the scripts that set the network configuration was in /etc/sysconfig/network-scripts. My network interface family was eth so the script that set it up was /etc/sysconfig/network-scripts/ifup-cfg. At the of end of the file was the command

exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2}

Reading the /etc/sysconfig/network-scripts/ifup-post file, I found the following command at the end.

if [ -x /sbin/ifup-local ]; then
    /sbin/ifup-local ${DEVICE}

However, the file /sbin/ifup-local does not exist. So I created one with the ntpdate -u command in it.  So now, every time the network is configured, the time is correct.
I know it doesn't address the problem of the battery being dead or needing replacement but it'll do for now.

This didn't work for you? Maybe you're using NetworkManager. Run NTPDate automatically with NetworkManager too.

Enhanced by Zemanta


  1. What happen if you don't have internet access? Will the clock still be up to date?

  2. Unfortunately, no. The solution depends on NTP which in turn depends on a network clock.
    If you don't have internet access but have more than 1 PC on the network under your control, you can install an NTP server on that PC. Add another ntpdate line with that PC's IP address like "ntpdate -u" in the /sbin/ifup-local file.


Recently Popular