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'));
30 if(function_exists('sys_getloadavg')) {
31 $load = sys_getloadavg();
32 if(intval($load[0]) > $maxsysload) {
33 logger('system: load ' . $load[0] . ' too high. Cronhooks deferred to next scheduled run.');
38 $last = get_config('system','last_cronhook');
40 $poll_interval = intval(get_config('system','cronhook_interval'));
45 $next = $last + ($poll_interval * 60);
47 logger('cronhook intervall not reached');
52 $lockpath = get_lockpath();
53 if ($lockpath != '') {
54 $pidfile = new pidfile($lockpath, 'cronhooks');
55 if($pidfile->is_already_running()) {
56 logger("cronhooks: Already running");
57 if ($pidfile->running_time() > 19*60) {
59 logger("cronhooks: killed stale process");
60 // Calling a new instance
61 proc_run('php','include/cronhooks.php');
67 $a->set_baseurl(get_config('system','url'));
71 logger('cronhooks: start');
73 $d = datetime_convert();
75 call_hooks('cron', $d);
77 logger('cronhooks: end');
79 set_config('system','last_cronhook', time());
84 if (array_search(__file__,get_included_files())===0){
85 cronhooks_run($_SERVER["argv"],$_SERVER["argc"]);