|
Posted by Leif Gregory on 02/14/05 06:43
Hello Brad,
Monday, February 7, 2005, 3:21:26 PM, you wrote:
BC> What is the function, or how do you make a script that displays
BC> the server's uptime?
If you're on Windows you could do this:
**************
function serverUptime()
{
$uptimeStamp = filemtime('c:/pagefile.sys');
$uptime = time() - $uptimeStamp;
$days = floor($uptime / (24*3600));
$uptime = $uptime - ($days * (24*3600));
$hours = floor($uptime / (3600));
$uptime = $uptime - ($hours * (3600));
$minutes = floor($uptime /(60));
$uptime = $uptime - ($minutes * 60);
$seconds = $uptime;
$theUpTime = $days." days, ".$hours." hours, ".$minutes." minutes and ".$seconds." seconds";
$lastReBoot = date("r", $uptimeStamp);
RETURN $theUpTime;
}
**************
It'll give you an output like this:
21 days, 6 hours, 48 minutes and 49 seconds
Note: I didn't write this code, this is how WinSysInfo does it. It
works very well. He's got a lot of neat code in his beta 2 version for
pulling all sorts of info off Windows systems.
If you're not on a Windows server, *nix might have a file other than
pagefile.sys that you could do the same thing with.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
Navigation:
[Reply to this message]
|