LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Funny uptime behaviour (https://www.linuxquestions.org/questions/linux-general-1/funny-uptime-behaviour-323723/)

paul.nel 05-15-2005 11:43 AM

Funny uptime behaviour
 
The command "uptime" is behaving rather strangely. My machine has been up for more than 50 days but uptime returns 7 days as result. I have one terminal window in which I regularly check the uptime and in the same terminal I have uptime results of 47 days and a few prompts later it says 7 days!

Strange. Any ideas?

p.n

AltF4 05-16-2005 07:50 PM

try "last reboot" command to verify

some cleanup script may have deleted/arcived your utmp/wtmp files

paul.nel 05-17-2005 01:58 PM

Indeed!

Code:

reboot  system boot  2.4.21-99-defaul Sat Mar 19 11:52        (59+10:17)
reboot  system boot  2.4.21-99-defaul Sat Mar 19 11:43          (00:07)
reboot  system boot  2.4.21-99-defaul Thu Mar 10 21:12        (8+14:19)
reboot  system boot  2.4.21-99-defaul Thu Feb 10 13:26        (36+22:06)
reboot  system boot  2.4.21-99-defaul Mon Feb  7 20:03        (39+15:28)
reboot  system boot  2.4.21-99-defaul Mon Dec 20 10:58        (46+12:51)
reboot  system boot  2.4.21-99-defaul Sun Nov 28 12:11        (21+21:40)
reboot  system boot  2.4.21-99-defaul Sat Nov  6 13:02        (43+20:49)

See, I told you it was up more than 50 days! Is there a way to fix uptime or should I just live with it?
Regards

AltF4 05-17-2005 07:42 PM

uptime reads "/var/run/utmp"
did some cleanup job purge/archive /var/run/utmp ?

AltF4 05-17-2005 07:58 PM

try this:

cat /proc/uptime | perl -e ' $T=<>; $D = ($T / (3600 * 24)); $H = 24*($D - int($D)); $D=int($D); $H=int($H); print "Uptime: $D days $H hours\n";'

paul.nel 05-18-2005 08:42 AM

mmmmm... before I do this, what is that I'll actually be doing?

AltF4 05-18-2005 12:34 PM

# print what the kernel thinks about uptime (seconds since 1970)
cat /proc/uptime
# format to days and hours
perl -e "....."

paul.nel 05-19-2005 01:49 PM

Well, the kernel says the same as 'uptime'. Uptime says 11 days and your command says 11 days. last reboot however reports the correct 61 days.


All times are GMT -5. The time now is 10:37 PM.