Difference between uptime and who -b

Hi Folks,

I have been checking on a redhat server for patching, when I tried the output for uptime and who -b both are not matching. I do not know the reason what happened and why it seems like this.

Please assist someone and explain in detail.
I would appreciate if I get the right answer.:slight_smile:

[svcsuprt@miaapp003 ~]$ uptime
18:54:03 up 187 days, 23:07, 1 user, load average: 0.12, 0.04, 0.02

[svcsuprt@miaapp003 ~]$ who -b
system boot 2014-08-10 18:24

[svcsuprt@miaapp003 ~]$ last reboot
reboot system boot 2.6.32-504.el6.x Sun Aug 10 18:24 - 18:54 (347+00:29)
wtmp begins Sun Aug 10 18:24:50 2014

Hello seenuvasan1985,

You can always refer man pages for options. Like as follows.
For uptime :

For who -b :

As above quotes, you can take one example who -b tells same like when a person(OS this case) born(came up) and uptime tells how old a person(OS this case, means what time it got rebooted last time) is. Just an silly and simple examples. Hope this helps you.

Thanks,
R. Singh

That doesn't answer the question. On my system, the command line:

date;uptime;who -b

produced the output:

Thu Jul 23 12:19:26 PDT 2015
12:19  up 22 days, 12:22, 10 users, load averages: 1.08 1.06 1.09
reboot   ~        Jun 30 23:55 

a few minutes ago. That shows a boot time reported by uptime about two minutes later than the time reported by who -b . I can blame that on the times being recorded at different phases in the boot process. I think seenuvasan1985 is asking why the timestamps on his system are ~6 months apart. Why did his system go down and come back up without rebooting?

Maybe someone took the system down to single user mode and then brought it back up to multi-user mode 187 days ago without rebooting???

Thanks Don Cragun,

Actually my question is why i am getting different output.

Uptime shows the server is running since 187days and who -b says the last reboot happened at 2014-08-10 (340 days).

Usuallay both should match, what could happed here!!!

Linux uptime command looks at file /proc/uptime and last reboot shows the reboot entry from /var/log/wtmp . The reboot entry is placed (I suppose) by init command and /proc/uptime shows uptime from the kernel's point of view - from starting the 1st CPU. Nobody knows your system better then you, but I would trust the output of uptime . wtmp file is easy to manipulate and it starts on the same date, as it shows last reboot. It may be, that last doesn't find any reboot entries at all and just reports the first entry of the file as last reboot time.

1 Like

Hi agent.kgb,

Thanks for your brief explanation. :slight_smile: