Jump to content

Get the last reboot from Server


bplogan

Recommended Posts

I have been assigned a project to create a page that displays the last reboot times of our company servers.  All servers are running MS Server 2003.  I found a way using ASP.NET but I hate ASP.NET with a passion.  Does anyone know of a way to use PHP or javascript to accomplish this?  Or does anyone have a different approach?  I think I may have to bite the bullet and use ASP, but hopefully someone can suggest something different.  Thanks.

Link to comment
Share on other sites

You could parse the log files and find the last occurance of the restart, or see if there is a specific file that is touched when a reboot occurs and use that information (with some PHP command line greps) to get the time and then do some math to figure out the time.

 

Link to comment
Share on other sites

Orrrr, you could switch to a Linux-based server (because Windows sucks) and just use the uptime command. >_>

 

As he stated in his post, it's for his company...sometimes we don't have the option to switch.

Link to comment
Share on other sites

Here's a fun one that I just made up now.

 

$lastRebootDate = exec("net statistics workstation | find /i \"Statistics since\"");
$lastRebootDate = str_replace("Statistics since ", "", $lastRebootDate);
echo $lastRebootDate;

Link to comment
Share on other sites

I'm not advocating Linux, I'm just saying that Windows does suck. =P  In general.  Especially for big servers.  And I'm sure Windows' feelings aren't hurt. =)

 

Not to start a war here but saying something sucks when its been number 1 for so long is a flat out lie.

 

Windows is designed around being portable and usable by a vast number of  users.  In doing this is leaves some of us who know more about computers limited in our capabilities to use our hardware to its max. 

Link to comment
Share on other sites

Windows is designed around being portable

 

Huh? It (windows) runs on two maybe three architectures. Linux runs on like 8-12.

 

In doing this is leaves some of us who know more about computers limited in our capabilities to use our hardware to its max.

 

And I'm sorry, but that makes no sense at all.

Link to comment
Share on other sites

efights aren't cool by any means but statistics wise, most php applications are ran from linux boxes. we are on a php forum, not aspx. php is open source, mysql is open source, nix is open source. keep it in the family.

Link to comment
Share on other sites

How about you guys just stop bickering about an endless argument and realise the question at hand.

How to get the last reboot time on Windows using PHP..

 

I believe a few solutions have been posted, and I'll have you know it was a pleasant conversation. I don't see any flamming going on.

Link to comment
Share on other sites

<?php
class weapon{
public function pick_weapon($weapon){
	$this->weapon = $weapon;
}
public function fire_weapon($weapon,$target){
	echo "You fired your ".$weapon." at ".$target;
	if(stristr($weapon, "fire")){
		echo "<br />and you burned them!";
	}
}
}
$weap = new weapon;
$weap->pick_weapon("Fire_Lazer");
$weapon->fire_weapon("Fire_Lazer","ShaunO");
$weapon->fire_weapon("Fire_Lazer","Jabop");
?>

 

:)

 

Link to comment
Share on other sites

<?php
class weapon{
public function pick_weapon($weapon){
	$this->weapon = $weapon;
}
public function fire_weapon($weapon,$target){
	echo "You fired your ".$weapon." at ".$target;
	if(stristr($weapon, "fire")){
		echo "<br />and you burned them!";
	}
}
}
$weap = new weapon;
$weap->pick_weapon("Flamethrower");
$weapon->fire_weapon("Flamethrower","ShaunO");
$weapon->fire_weapon("Flamethrower","Jabop");
?>

 

:)

 

 

Hehe, its a shame that code would output nothing but errors ;)

Link to comment
Share on other sites

Not sure if it will help, but a quick command via command prompt in windows is

(for xp)  systeminfo | find "System Up Time"

(for vista)  systeminfo | find "System Boot Time"

 

might be able to use shell_exec() or something to get it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.