3 Load this script to make use of the tools/cron.d/ utilities without
4 having to set up a real cron(8) daemon rule. But please use this
5 only if you have no other choice, as it could slow down your Web
6 server. This snippet activates the run-parts in PHP shutdown mode
7 around every second hour (depends on how many users/bots walk over
9 You must run the cron.d/ run-parts script _ONCE_ before this works,
10 because this does not create the required+special database entry.
13 define("EWIKI_ANACRON_INTERLEAVE", 2*3600); // in seconds
14 define("EWIKI_ANACRON_ID", "etc/anacron/last-run"); // a _SYSTEM entry
17 #-- checks elapsed timeframe, and installs _runparts for shutdown action
18 $ewiki_plugins["init"][] = "ewiki_anacron_checktime";
19 function ewiki_anacron_checktime() {
20 global $ewiki_plugins;
21 if ( ($d = ewiki_db::GET(EWIKI_ANACRON_ID))
22 and ($d = unserialize($d["content"]))
23 and ($d["last"] >= UNIX_MILLENNIUM)
24 and (time() >= $d["last"] + EWIKI_ANACRON_INTERLEAVE) )
26 register_shutdown_function("ewiki_anacron_runparts");
31 #-- every two hours: starts run-parts
32 function ewiki_anacron_runparts() {
34 // clean up env, because we've been triggered by someone innocent
35 $_SERVER["REMOTE_ADDR"] = "0.0.0.0";
36 $_SERVER["REMOTE_PORT"] = "-";
37 $ewiki_author = "ewiki_anacron_runparts";
39 // only works for more or less standard installations
40 include(EWIKI_BASE_DIR."/tools/cron.d/run-parts.php");