public function index()
 {
     $scripts = Script::find_all();
     $this->assign("scripts", $scripts);
     if ($this->xhr) {
         $this->render("script/_index.tpl", true);
     } else {
         $this->title = "Scheduled Scripts";
         $this->render("script/index.tpl");
     }
 }
Exemplo n.º 2
0
<?php

require_once 'init.php';
ob_start();
$script = Script::find_by_code('scheduler');
$script->start();
$scripts = Script::find_all("scripts.code <> 'scheduler' AND scripts.enabled AND (scripts.started_at + scripts.interval) < NOW() AND not scripts.locked");
foreach ($scripts as $script) {
    if (!$script->locked && $script->started_at + $script->interval < time()) {
        echo date('   [d/m/y H:i:s]') . " Executing {$script->name}\r\n";
        // Execute a background process to run this script
        $script->run(true);
    }
}
$scheduler = Script::find_by_code('scheduler');
$output = ob_get_clean();
$script = Script::find_by_code('scheduler');
$script->finish($output);