3 The ewiki/tools/cron.d/ run-parts wrapper looks at all the files in
4 its own directory and simply includes() one after another. Scripts
5 found herein typically accomplish admistrative tasks that require no
8 All S** parts are run in ascending order, then Z** and any K** parts
9 get run in reverse order. The former is stopped when one of the
10 scripts sets the $HALT or $STOP variables. The latter can be prevented
12 There is also a $GOTO variable available, which allows to overstep a
13 few scripts by numeric id (the anacron snippets use that).
15 Please see the HOWTO on more notes on how to activate this.
19 #-- read in current directory
20 $dir = dirname(__FILE__);
21 $startparts = array();
23 if ($dh = opendir($dir)) {
24 while ($fn = readdir($dh)) {
25 if (preg_match("/^[SKZ]\d\d.+\.php$/", $fn)) {
27 $startparts[] = "$dir/$fn";
30 $killparts[] = "$dir/$fn";
38 #-- run 'S'tart-scripts
42 foreach ($startparts as $fn) {
44 #-- make script id string from filename
45 $cron = strtok(substr($fn, strrpos($fn, "/") + 1), ".");
47 #-- overstep a few scripts, if instructed to do so
48 $num = substr($cron, 1, 2);
49 if ($GOTO && ($num<$GOTO)) {
63 #-- reverse order for 'K'ill and 'Z'leep -scripts
64 if ($killparts && ($HALT < 2)) {
66 foreach ($killparts as $fn) {
67 $cron = strtok(substr($fn, strrpos($fn, "/") + 1), ".");
74 $startparts=$killparts=$cron=$fn=$STOP=$HALT=NULL;
75 // something else may follow here