cron.php 509 Bytes
Newer Older
1 2
<?

Dries's avatar
Dries committed
3
include "includes/common.inc";
4

Dries's avatar
Dries committed
5
function cron_run() {
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  global $repository;

  $time = time();
  
  $result = db_query("SELECT * FROM crons WHERE $time - timestamp > scheduled");

  while ($task = db_fetch_object($result)) {
    if ($repository[$task->module]["cron"]) {
      watchdog("message", "cron: executed '". $task->module ."_cron()'"); 
      $repository[$task->module]["cron"]();
    }
  }

  db_query("UPDATE crons SET timestamp = $time WHERE $time - timestamp > scheduled");
}
21

22
cron_run();
23

24
?>