note 62557 added to function.sys-getloadavg
| From: | tompittlik at osu1 dot php dot net | Date: | Fri, 03 Mar 2006 10:36:21 +0000 |
| Subject: | note 62557 added to function.sys-getloadavg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104759@lists.php.net to get a copy of this message | ||
The code below mimics the output of sys_getloadavg(). You may have to tweak the way the substring is
captured for different distros.
<?
function sys_getloadavg_hack()
{
$str = substr(strrchr(shell_exec("uptime"),":"),1);
$avs = array_map("trim",explode(",",$str));
return $avs;
}
print_r(sys_getloadavg_hack());
// Array
// (
// [0] => 6.24
// [1] => 4.92
// [2] => 3.99
// )
?>
This function is a neat way of running low priority or non-essential cron jobs on a busy server - if
the load is high, don't continue with the task (and try again in a few minutes time).
----
Server IP: 203.16.234.20
Probable Submitter: 59.167.36.44
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.sys-getloadavg.php
Edit -- http://master.php.net/note/edit/62557
Del: integrated -- http://master.php.net/note/delete/62557/integrated
Del: useless -- http://master.php.net/note/delete/62557/useless
Del: bad code -- http://master.php.net/note/delete/62557/bad+code
Del: spam -- http://master.php.net/note/delete/62557/spam
Del: non-english -- http://master.php.net/note/delete/62557/non-english
Del: in docs -- http://master.php.net/note/delete/62557/in+docs
Del: other reasons-- http://master.php.net/note/delete/62557
Reject -- http://master.php.net/note/reject/62557
Search -- http://master.php.net/manage/user-notes.php