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 $maxsysload = intval(get_config('system','maxloadavg'));
31 $load = current_load();
33 if(intval($load) > $maxsysload) {
34 logger('system: load ' . $load . ' too high. Cronhooks deferred to next scheduled run.');
39 $last = get_config('system','last_cronhook');
41 $poll_interval = intval(get_config('system','cronhook_interval'));
46 $next = $last + ($poll_interval * 60);
48 logger('cronhook intervall not reached');
53 $lockpath = get_lockpath();
54 if ($lockpath != '') {
55 $pidfile = new pidfile($lockpath, 'cronhooks');
56 if($pidfile->is_already_running()) {
57 logger("cronhooks: Already running");
58 if ($pidfile->running_time() > 19*60) {
60 logger("cronhooks: killed stale process");
61 // Calling a new instance
62 proc_run('php','include/cronhooks.php');
68 $a->set_baseurl(get_config('system','url'));
72 logger('cronhooks: start');
74 $d = datetime_convert();
76 call_hooks('cron', $d);
78 logger('cronhooks: end');
80 set_config('system','last_cronhook', time());
85 if (array_search(__file__,get_included_files())===0){
86 cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);