Voting

: max(three, six)?
(Example: nine)

The Note You're Voting On

tom pittlik
19 years ago
The code below mimics the output of sys_getloadavg(). You may have to tweak the way the substring is captured for different distros.

<?php

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).

<< Back to user notes page

To Top