4.12.06
Linux server uptime stats
Here's a bit of code to grab and display Linux uptime using PHP. It's a cleaned up version of a something I found online. I would give credit, but I can't remember where I originally got it from. Anywho, enjoy!
$uptime = shell_exec("cut -d. -f1 /proc/uptime");
$d = floor($uptime/60/60/24);
if ($d == 0){} else {
if ($d == 1) { $days = "$d day";} else { $days = "$d days";}}
$h = $uptime/60/60%24;
if ($h == 1) { $hours = "$h hour";} else { $hours = "$h hours";}
$m = $uptime/60%60;
if ($m == 1) { $mins = "$m minute";} else { $mins = "$m minutes";}
$s = $uptime%60;
if ($s == 1) { $secs = "$s second";} else { $secs = "$s seconds";}
echo "Server Uptime:
$days $hours $mins and $secs";
0 ramblings so far

4:23 pm in