wrong uptime

Matthew Dillon dillon at apollo.backplane.com
Fri Apr 2 20:52:15 PST 2004

:Is anyone else seeing incorrect uptime like this? I've been seeing this
:(and sometimes negative uptime) since the last changes to the clock code.
:$ uptime; last -4 reboot shutdown
:12:32PM  up 2 days, 14:46, 2 users, load averages: 0.00, 0.03, 0.00
:reboot           ~                         Sat Apr  3 11:53
:shutdown         ~                         Wed Mar 31 21:46
:reboot           ~                         Wed Mar 31 20:46
:shutdown         ~                         Sat Mar 27 18:59
:uptime(1) uses kern.boottime to calculate the period of time since boot,
:but now kern.boottime seems to answer the last shutdown time, and
:kern.basetime is what does the job.
:$ sysctl kern.boottime kern.basetime
:kern.boottime: { sec = 1080737205, usec = 890150874 } Wed Mar 31 21:46:45 2004
:kern.basetime: { sec = 1080960819, usec = 890099279 } Sat Apr  3 11:53:39 2004

    Yes, I think you're right.  boottime is in fact the correct base to use,
    but it is not being properly set.  This has been reported before, I just
    didn't have time to look at it before.

    During boot the itme of day gets set in two places:  From the filesystem
    superblock and from the realtime clock.

    It looks like the system is ignoring the second setting in regards to
    adjusting boottime... that code was designed to prevent small adjustments
    from changing the boottime after the fact.

    I get the same issue when I compare my logs against the sysctls too.  

    I will commit the appropriate fix.

					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>

More information about the Bugs mailing list