LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-15-2005, 11:43 AM   #1
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Rep: Reputation: 15
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
 
Old 05-16-2005, 07:50 PM   #2
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
try "last reboot" command to verify

some cleanup script may have deleted/arcived your utmp/wtmp files
 
Old 05-17-2005, 01:58 PM   #3
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Original Poster
Rep: Reputation: 15
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
 
Old 05-17-2005, 07:42 PM   #4
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
uptime reads "/var/run/utmp"
did some cleanup job purge/archive /var/run/utmp ?
 
Old 05-17-2005, 07:58 PM   #5
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
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";'
 
Old 05-18-2005, 08:42 AM   #6
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Original Poster
Rep: Reputation: 15
mmmmm... before I do this, what is that I'll actually be doing?
 
Old 05-18-2005, 12:34 PM   #7
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
# print what the kernel thinks about uptime (seconds since 1970)
cat /proc/uptime
# format to days and hours
perl -e "....."
 
Old 05-19-2005, 01:49 PM   #8
paul.nel
Member
 
Registered: Nov 2003
Location: Cape Town
Distribution: Gentoo, Redhat 9, SuSE 9.0, 9.2, Win XP
Posts: 149

Original Poster
Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Uptime: 2.4 vs 2.6 Synesthesia Linux - General 4 10-17-2005 03:23 PM
24/7 uptime? jollyjoice General 20 01-25-2005 11:12 AM
uptime skate Linux - Software 16 08-14-2003 03:10 AM
RedHat 6.2 uptime mjakob Linux - General 5 12-14-2002 10:23 PM
Funny mouse behaviour cruane Linux - Hardware 5 09-25-2002 03:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration