PDA

View Full Version : Check System Uptime?



trenzterra
November 19th, 2003, 23:40
How do I check my system uptime on both Windows and Redhat?

CareBear
November 20th, 2003, 03:35
You didn't say which Windows :confused5

If you want something easy, try:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
dtmSystemUptime = DateDiff("s", dtmLastBootUpTime, Now)
Wscript.Echo "Uptime: " & (int)(dtmSystemUptime / 86400) & " day(s) " & _
(int)((dtmSystemUptime Mod 86400) / 3600) & " hour(s) " & _
(int)((dtmSystemUptime Mod 3600) / 60) & " minute(s) " &_
(int)(dtmSystemUptime Mod 60) & " second(s)"
Next

Function WMIDateStringToDate(dtmBootup)
WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid (dtmBootup, 9, 2) & ":" & _
Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup, _
13, 2))
End FunctionSave it as uptime.vbs and just doubleclick :)

If you need something more advanced you can try: http://www.microsoft.com/ntserver/nts/downloads/management/uptime/default.asp
It will show you something like:

Current OS: Microsoft Windows XP, Service Pack 1, Uniprocessor Free.
Time Zone: Romance Standard Time

System Events as of 20/11/2003 10:31:29:

Date: Time: Event: Comment:
---------- ----------- ------------------- -----------------------------------
05/09/2003 08:23:43 Shutdown
05/09/2003 08:24:52 Boot Prior downtime:0d 0h:1m:9s
06/09/2003 07:27:58 Shutdown Prior uptime:0d 23h:3m:6s
06/09/2003 13:22:46 Boot Prior downtime:0d 5h:54m:48s
08/09/2003 14:50:04 Shutdown Prior uptime:2d 1h:27m:18s
*snip*
Current System Uptime: 0 day(s), 9 hour(s), 22 minute(s), 38 second(s)

--------------------------------------------------------------------------------

Since 05/09/2003:

System Availability: 99.0469%
Total Uptime: 75d 9h:42m:51s
Total Downtime: 0d 17h:24m:55s
Total Reboots: 20
Mean Time Between Reboots: 3.81 days
Total Bluescreens: 1

trenzterra
November 20th, 2003, 06:39
Windows XP.

What about RH9?

Robert
November 20th, 2003, 07:32
Originally posted by trenzterra
Windows XP.

What about RH9?


in RH9 just open the command prompt (telnet, ssh, the console) and type "uptime"


[admin admin]$ uptime
8:22am up 398 days, 22:29, 1 user, load average: 0.00, 0.00, 0.00
[admin admin]$

trenzterra
November 20th, 2003, 07:47
how would u get it show in Xchat? I forgot...

ANyway i have 3 days uptime, trick is hibernation :)