0

I would like to know if its possible to write a code in php similar to a cron script to run at a particular time when there is no traffic on site, that means i want the code to run without loading the site. Also I do not want to create a cron job on the server.

1 Answers1

1

You can check if server is no too busy, run a cron job:

There's a function for that: http://www.php.net/manual/en/function.sys-getloadavg.php

example usage:

<?php
$maxLoad = 10; //set some number of max  of processes in the system 
$load = sys_getloadavg();
if ($maxLoad < $load[0]) {
    //run a cron job
}
sergio
  • 5,210
  • 7
  • 24
  • 46