This is a pretty simple way of getting the server uptime using PHP. Note that this only works on Linux (and probably other Unix-like OSes that store the machine uptime in
/proc/uptime
). Straight to the code:
function get_uptime() {
$file = @fopen('/proc/uptime', 'r');
if (!$file) return 'Opening of /proc/uptime failed!';
$data = @fread($file, 128);
if ($data === false) return 'fread() failed on /proc/uptime!';
$upsecs = (int)substr($data, 0, strpos($data, ' '));
$uptime = Array (
'days' => floor($data/60/60/24),
'hours' => $data/60/60%24,
'minutes' => $data/60%60,
'seconds' => $data%60
);
return $uptime;
}
Whats the point of $upsecs?
ReplyDeleteMaybe you're meant to use it in $uptime?
trabzon
ReplyDeleteedirne
van
bingöl
yalova
2GVTE