3 require_once("boot.php");
6 function cronhooks_run(&$argv, &$argc){
14 @include(".htconfig.php");
15 require_once("include/dba.php");
16 $db = new dba($db_host, $db_user, $db_pass, $db_data);
17 unset($db_host, $db_user, $db_pass, $db_data);
20 require_once('include/session.php');
21 require_once('include/datetime.php');
22 require_once('include/pidfile.php');
24 load_config('config');
25 load_config('system');
27 // Don't check this stuff if the function is called by the poller
28 if (App::callstack() != "poller_run") {
29 $maxsysload = intval(get_config('system','maxloadavg'));
33 $load = current_load();
35 if(intval($load) > $maxsysload) {
36 logger('system: load ' . $load . ' too high. Cronhooks deferred to next scheduled run.');
41 $lockpath = get_lockpath();
42 if ($lockpath != '') {
43 $pidfile = new pidfile($lockpath, 'cronhooks');
44 if($pidfile->is_already_running()) {
45 logger("cronhooks: Already running");
46 if ($pidfile->running_time() > 19*60) {
48 logger("cronhooks: killed stale process");
49 // Calling a new instance
50 proc_run('php','include/cronhooks.php');
57 $last = get_config('system','last_cronhook');
59 $poll_interval = intval(get_config('system','cronhook_interval'));
64 $next = $last + ($poll_interval * 60);
66 logger('cronhook intervall not reached');
71 $a->set_baseurl(get_config('system','url'));
75 logger('cronhooks: start');
77 $d = datetime_convert();
79 call_hooks('cron', $d);
81 logger('cronhooks: end');
83 set_config('system','last_cronhook', time());
88 if (array_search(__file__,get_included_files())===0){
89 cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);