From owner-freebsd-hackers Thu Sep 20 4:51:45 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from vbook.express.ru (asplinux.ru [195.133.213.194]) by hub.freebsd.org (Postfix) with ESMTP id D21DF37B421; Thu, 20 Sep 2001 04:51:38 -0700 (PDT) Received: from vova by vbook.express.ru with local (Exim 3.31 #2) id 15k2Nl-0000tr-00; Thu, 20 Sep 2001 15:52:41 +0400 From: "Vladimir B. Grebenschikov" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15273.55432.957586.417711@vbook.express.ru> Date: Thu, 20 Sep 2001 15:52:40 +0400 To: Michael Sinz Cc: FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: uptime and w utilities lie about real uptime In-Reply-To: <402390ae04246407d1@[192.168.1.4]> References: <400de87e0423b007d1@[192.168.1.4]> <402390ae04246407d1@[192.168.1.4]> X-Mailer: VM 6.95 under 21.1 (patch 12) "Channel Islands" XEmacs Lucid Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Michael Sinz writes: > > if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && > > boottime.tv_sec != 0) { > > uptime = now - boottime.tv_sec; > > uptime += 30; > > ====================== ^^^^^ > > days = uptime / 86400; > > uptime %= 86400; > > hrs = uptime / 3600; > > uptime %= 3600; > > mins = uptime / 60; > > secs = uptime % 60; > > (void)printf(" up"); > > > > why utility increases uptime on 30 seconds ?? > > Is any real reasons for it ? > > >From my reading of this, it seems to want to round the uptime to > the nearest minute -- afterall, w and uptime both only show the uptime > in minutes (well, days, hours, and minutes) not exactly right: ... DUMMYNET initialized (010124) Waiting 2 seconds for SCSI devices to settle SMP: AP CPU #1 Launched! Mounting root from ufs:/dev/da0s2a da0 at ahc0 bus 0 target 12 lun 0 da0: Fixed Direct Access SCSI-3 device da0: 80.000MB/s transfers (40.000MHz, offset 31, 16bit), Tagged Queueing Enabled da0: 8748MB (17916240 512 byte sectors: 255H 63S/T 1115C) Enter full pathname of shell or RETURN for /bin/sh: # mount -a # uptime 3:12PM up 42 secs, 3 users, load averages: 0.21, 0.05, 0.02 # 42sec instead of more realistic 12sec looking into w.c more: if (days > 0) (void)printf(" %d day%s,", days, days > 1 ? "s" : ""); if (hrs > 0 && mins > 0) (void)printf(" %2d:%02d,", hrs, mins); else if (hrs > 0) (void)printf(" %d hr%s,", hrs, hrs > 1 ? "s" : ""); else if (mins > 0) (void)printf(" %d min%s,", mins, mins > 1 ? "s" : ""); else (void)printf(" %d sec%s,", secs, secs > 1 ? "s" : ""); } -- TSB Russian Express, Moscow Vladimir B. Grebenschikov, vova@express.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message