I have a Linux system where it is showing to me two different times when the system was last booted.
root@linux:~ # who -b; uptime
system boot 2009-07-09 20:51
11:48am up 1 day 0:54, 1 user, load average: 0.01, 0.03, 0.00
I presume that who is showing the content of /var/log/wtmp and uptime I have no idea.
Is there some way to fix this difference? I rebooted the system yesterday so I know the contents that uptime is showing me is correct.
Best Answer
[I caught some misconceptions here which I think will this post clear off eventually]
There should not be any difference since both refer to
/var/run/utmp
file, which has its own format to store the records. If at all there is any difference, then your utmp file is busted. uptime shows the amount of time that has passed since the system has been booted or how long the system has been running. It does not tell you the system clock or system boot time . System boot time information is stored/var/run/wtmp
file.uptime refers as well /proc/uptime, which essentially keeps the counters in kernel.
/var/run/wtmp
is referred by last/lastb commands.who
&w
refers/var/run/utmp
file.last reboot
will show a log of all reboots since the log file was created.Additionally, if you are having /proc filesystem, then tool such as
procinfo
can give you bootup time as well.Example: