Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when did my server boot 1

Status
Not open for further replies.

ray88

Technical User
Jan 19, 2004
16
CH
where can i see in the event log when my windows 2003 server booted last time

thx
 
Look for event ID 6009 in the System log with the source of eventlog.

Note: you can also run:
NET STATISTICS SERVER|MORE
from a command line and that will tell you the last time the server service started (exact day and time). Since the Server service is RARELY restarted this is a good (but not 100 certain) way of knowing when the server last booted.
 
thanks for that answer

unfortunately neither of your propositions work

event 6009 in my system event log shows somethings about my multiprocessor

and net statistics servers shows me some statistics but nothing about when or whether my server ever booted

thanks anyhow

ray
 
The Second line of text when you run NET STATISTICS SERVER is "Statistics since <date/time>" - that "<date/time>" is when the service started.

Server Statistics for \\COMPUTER

Statistics since 5/21/2007 4:18 AM

Sessions accepted 1
Sessions timed-out 14
Sessions errored-out 14

Kilobytes sent 596145
Kilobytes received 1015166

Mean response time (msec) 0

System errors 0
Permission violations 12
Password violations 13

Files accessed 1119
Communication devices accessed 0
Print jobs spooled 0

Times buffers exhausted

Big buffers 0
Request buffers 0

The command completed successfully.
 
Further, Yes, it notes "Microsoft (R) Windows (R) 5.02. 3790 Service Pack 1 Multiprocessor Free." Or something similar. It does this as the first event recorded during a boot. If you want to know when the system booted, you look for this ID.

What did you think the event ID would say?
 
now its more clear thankts for these hints
 
An easier way is to use WMI and just query the box. I knew the new function I made for DateDiff would have more uses. :)

The following script will report both the last reboot date and how long the system has been running. Just save the below text to a text file and name it ReportSystemUptime.vbs. Double click to launch. Note you can query a remote system by changing the period in the line:

strComputer = "."

Change the period to the name or IP of the remote system.

Code:
'==========================================================================
'
' NAME: ReportSystemUptime.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 06/10/2007
' COPYRIGHT (c) 2007 All Rights Reserved
'
' COMMENT: 
'
'    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED To
'    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'==========================================================================

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
	lastBootTime = dConvertWMItoVBSDate(objItem.LastBootUpTime)
	
    MsgBox "LastBootUpTime: " & lastBootTime & vbCrLf & _ 
    "System Uptime: " & datediffToWords(lastBootTime, Now)
Next
Private Function dConvertWMItoVBSDate(sDate)
  Dim sMonth, sDay, sYear, sHour, sMinutes, sSeconds
  sMonth = Mid(sDate,5,2)
  sDay = Mid(sDate,7,2)
  sYear = Mid(sDate,1,4)
  sHour = Mid(sDate,9,2)
  sMinutes = Mid(sDate,11,2)
  sSeconds = Mid(sDate,13,2)
  dConvertWMItoVBSDate = DateSerial (sYear, sMonth, sDay) + TimeSerial (sHour, sMinutes, sSeconds)
End Function


Function datediffToWords(d1, d2) 
        report = ""
        'Start with total number of days
        days = DateDiff("d",d1,d2)
  		'Convert days to years and grab remaining days
		If days > 365 Then
			years = days\365
			days = days Mod (365*years)-1
			report = years & " Year(s), "
		Else 
			years = 0	
		End If
		'Thank you PHV for help simplifying the month calculation
		'Compute the number of months
		months = Int(DateDiff("m",d1,d2))+(day(d2)<day(d1))
		'remove years from the total months
		months = months Mod 12
		If months > 0 Then
			report = report & Months & " Month(s), "
		End If
		'now find the days
		newStart = Month(d1) & "/" & Day(d1) & "/" & Year(d1) + years
		If Month(d1) <> 12 Then
			fullmonthStart = Month(d1) + 1 & "/1/" & Year(d1) + years
		Else
			fullmonthStart = "1/1/" & Year(d1) + years +1
		End If
		
		If Day(d1) =< Day(d2) Then
			days = Day(d2) - Day(d1)
		Else
			days = DateDiff("d", newStart, fullmonthStart) + Day(d2) -1
		End If
        If days > 0 Then
        	report = report & days & " day(s), "
        End If	
        
        'now we will deal with the time left over
        'begin by getting total seconds between dates and divide out the days
        'grab the remaining seconds with the mod operator
        Seconds = abs(datediff("S", d1, d2)) 
        if Seconds <= 0 then 
            report = "0 seconds." 
        else 
	        Seconds = Seconds mod (24*60*60) 
	        'divide by 3600 to get hours
	        If Seconds >= 3600 then 
	            report = report & _  
	            Seconds\(3600) & " hours(s), " 
	        end If
	        'use mod to get remaining seconds and divide to get minutes
	        Seconds = Seconds mod (60*60) 
	        if Seconds >= 60 then 
	            report = report & _  
	            Seconds\(60) & " minutes(s), " 
	        end If
	        'use mod to get remaining seconds
	        seconds = Seconds Mod (60) 
	        report = report & seconds & " second(s)"
        end if 
        datediffToWords = report 
End Function

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
There are PLENTY of utilities available to give uptime information, but I would hardly call this easier when you consider that the script above does NOT come with Windows.

To me, something is easy when it's built in and quick.

Again, nothing wrong with the script, but I would not consider it easier.
 
Well you don't need a script to access WMI.

The following command will return the information from a command prompt.

Code:
wmic OS Where (Primary="TRUE") Get LastBootUpTime

This returns the date/time in UTC, but you can easily enough read the date. The first 8 digits are Year Month Day.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
To me, something is easy when it's built in and quick.

Again, nothing wrong with the script, but I would not consider it easier.

Just a follow up because I take my scripting so seriously. (I know that no offense was intended and I am not reading it that way).

I realize that not everyone can script and therefore scripting may not be the simplest solution for everyone, but once a script is written and copied to a system or accessed from a remote share, then a simple double click is surely easier than a command line interface.

Just my personal feeling.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
lol, seem to become a big issue... thanks all
 
I agree - scripting is VERY useful, but in my experience as a consultant, I find it better to know the ways that are built in to quickly identify information. There are times when getting hold of tools - including scripts - can simply be difficult.

One thing I like about checking the event log, you can filter by IDs and sources and see Every boot since the log was cleared or at least in the logs history (assuming you have it autoclearing).
 
Not a big deal, I think I worded this wrong:
(I know that no offense was intended and I am not reading it that way).

What I meant was I was not taking offense it it. I realized in looking back that the use of the word NOT in the above context could have two meanings.

All is well. :)

Mark
 
microsoft has one million types of events.. why they not just created an envent which simple says "system has restarted".. ..

thanks all again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top