Anyone have a neat PHP script for determining how long their Apache 2 server running under Windows (7 in my case) has been up? I've come up with this which seems to work but was wondering if any9one else had anything better?
function Uptime()
{
$httpdfile = 'D:\Apache2.2\logs\httpd.pid';
function ifif ($value, $true, $false)
{
if ($value < 2)
return $false;
else
return $true;
}
As you can see it's based off the date and time the Apache httpd.pid file was last written, which as far as I can tell, is written each time the Apache service is started. Output looks like this:
Up since: Wednesday, October 12th 2011, 08:08 pm
Server uptime: 24 days 23 hours 15 minutes 19 seconds
Thanks Terry. I saw that one too but it's not as clean as what I already have and requires one more external program. I'll take a look to see what uptime.exe provides though.
Edit: Actually a nice program. Output looks like this:
\\XXXXXXXX has been up for: 0 day(s), 2 hour(s), 23 minute(s), 56 second(s)
Numbers match output of my PHP script so I'm very confident what I'm using is valid. Good to have a backup though,
One nice addition is that I can use uptime to query a networked computer.
glad it was of some help, even if just to confirm what your using now is accurate.
Still having this problem?
This topic is from the What the Tech archive and can't take new replies. Geeks to Go is an active, free help community run by volunteers. Post your question there and a person, not a bot, will work through it with you.