settimeofday() & reboot or power cycle

C M Reinehr cmr
Wed Jan 17 13:53:21 PST 2007


Susan,

On Wednesday 17 January 2007 15:30, Susan Macchia wrote:
> Hi List,
>
>
>
> I have a conundrum I am trying to figure out.  I have a Mandriva 2006
> system.  The kernel is 2.6.12-12mdksmp.
>
> I have a process that runs (as root) that calls settimeofday().
> The time is changed and reflected in the UI.  The problem is this:
>
>
>
> When
> the system is shutdown and restared cleanly the change in time/date sticks.
>  If instead the power cycle button is pressed (causing an "unclean"
> shutdown), the time/date DOESN'T stick (and this is the bug).  I tried
> waiting for 1/2-1 hour, executing the sync command and the time still
> doesn't stick.
>
> I also tested this out with the "date" command (independent of my
> application) and saw the same phenomenon.
>
> Does anyone know if there is a known bug in the kernel?  Does anyone know
> if there is a patch or work-around?  Iv'e scoured the kernel.org archives
> and googled, but haven' found much.
>
> Much appreciated,
> Susan

I can only speak for Debian but your experience sounds similar to how Debian 
works. There is a file called hwclock.sh in /etc/init.d that is run once when 
the system is started & once when it is shutting down. In particular, when 
shutting down, the hwclock is updated with the current system time (which is 
kept accurate with ntpdate & ntp). If you do an abnormal system shutdown, 
without executing the normal shutdown scripts, then the hardware clock would 
not be updated with the current system time.

Hope this helps!

cmr 
-- 
Debian 'Etch' - Registered Linux User #241964
--------
"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC



More information about the Linux-users mailing list