Exemplo n.º 1
0
 /**
  * Executes the cronjob.
  *
  * @param mixed $last_result What the last execution of this cronjob
  *                           returned.
  * @param Array $parameters Parameters for this cronjob instance which
  *                          were defined during scheduling.
  */
 public function execute($last_result, $parameters = array())
 {
     $event_log = new EventLog();
     $event_log->cleanup_log_events();
     if (!empty($parameters['cronjobs'])) {
         $delete = function ($l) {
             $l->delete();
         };
         if ($parameters['cronjobs-error'] > 0) {
             CronjobLog::findEachBySql($delete, "exception != 'N;' AND executed + ? < UNIX_TIMESTAMP()", array($parameters['cronjobs-error'] * 24 * 60 * 60));
         }
         if ($parameters['cronjobs-success'] > 0) {
             CronjobLog::findEachBySql($delete, "exception = 'N;' AND executed + ? < UNIX_TIMESTAMP()", array($parameters['cronjobs-success'] * 24 * 60 * 60));
         }
     }
 }