Example #1
0
 /**
  * Action to display detailed status of current available tasks
  */
 public function actionIndex()
 {
     $this->_service->loadTasks();
     /** @var CronTask $task */
     foreach ($this->_service->getActiveTasks() as $task) {
         $process = $task->getProcessInfo();
         echo "Task '{$task->getName()}':\n";
         $output = $task->getOutputFile() ? " > {$task->getOutputFile()}" : '';
         $params = array();
         foreach ($task->getParams() as $key => $value) {
             $params[] = "--{$key}={$value}";
         }
         echo "{$task->getCron()} {$task->getCommand()} {$task->getCommandAction()} ";
         echo implode(' ', $params) . "{$output}\n";
         echo "Last start: {$process->lastStart}     Last finish: {$process->lastStop}     ";
         echo 'Status: ';
         switch ($process->status) {
             case CronProcess::STATUS_NEW:
                 echo 'NEW (not started yet)';
                 break;
             case CronProcess::STATUS_RUNNING:
                 echo "RUNNING (PID: {$process->pid})";
                 break;
             case CronProcess::STATUS_FINISHED:
                 echo 'FINISHED';
                 break;
             case CronProcess::STATUS_FAILED:
                 echo 'FAILED';
                 break;
         }
         echo "\n\n";
     }
 }
Example #2
0
 public function runJob($jobId)
 {
     include_once OPENBIZ_APP_PATH . "/bin/cronjob/cronService.php";
     $cronSvc = new CronService();
     $cronSvc->outputLog = true;
     print "Run job #{$jobId} ...<br/>";
     print "<textarea readonly style=\"width:100%;height:90%\">";
     $cronSvc->runJob($jobId);
     print "</textarea>";
 }
Example #3
0
 /**
  * Check if task process really active and running
  */
 private function checkProcessAvailability()
 {
     if ($this->pid !== null && $this->status === self::STATUS_RUNNING) {
         exec("ps -p {$this->pid} -o pid", $output);
         if (count($output) != 2) {
             $this->pid = null;
             $this->status = self::STATUS_FAILED;
             CronService::log("Task '{$this->name}' unexpectedly finished. Check logs and console command", CLogger::LEVEL_ERROR);
         }
     }
 }
Example #4
0
#!/usr/bin/php
<?php 
/*
 * cron job controller script
 * it reads the cronjob table and runs command based on the command settings 
 * #!/usr/bin/env php path is not work with cronjob, so have to replace it to an absulately path
 * like 
 */
if (is_file(dirname(dirname(dirname(__FILE__))) . '/files/install.lock') && filesize(dirname(dirname(dirname(__FILE__))) . '/files/install.lock') == 1) {
    include_once dirname(dirname(__FILE__)) . "/app_init.php";
    include_once dirname(__FILE__) . "/cronService.php";
    $cronSvc = new CronService();
    print date("m/d/Y H:i:s") . " START cron processor" . PHP_EOL;
    $cronSvc->run();
    print date("m/d/Y H:i:s") . " END cron processor" . PHP_EOL;
} else {
    echo "Openbiz Cubi not installed yet.";
    exit;
}