Example #1
0
 /**
  * Returns the scheduler object. Implements the singleton pattern to
  * ensure that only one scheduler exists.
  *
  * @return CronjobScheduler The scheduler object
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Schedules this task for periodic execution with the provided schedule.
  *
  * @param mixed  $minute      Minute part of the schedule:
  *                            - null for "every minute" a.k.a. "don't care"
  *                            - x < 0 for "every x minutes"
  *                            - x >= 0 for "only at minute x"
  * @param mixed  $hour        Hour part of the schedule:
  *                            - null for "every hour" a.k.a. "don't care"
  *                            - x < 0 for "every x hours"
  *                            - x >= 0 for "only at hour x"
  * @param mixed  $day         Day part of the schedule:
  *                            - null for "every day" a.k.a. "don't care"
  *                            - x < 0 for "every x days"
  *                            - x > 0 for "only at day x"
  * @param mixed  $month       Month part of the schedule:
  *                            - null for "every month" a.k.a. "don't care"
  *                            - x < 0 for "every x months"
  *                            - x > 0 for "only at month x"
  * @param mixed  $day_of_week Day of week part of the schedule:
  *                            - null for "every day" a.k.a. "don't care"
  *                            - 1 >= x >= 7 for "exactly at day of week x"
  *                              (x starts with monday at 1 and ends with
  *                               sunday at 7)
  * @param String $priority   Priority of the execution (low, normal, high),
  *                           defaults to normal
  * @param Array  $parameters Optional parameters passed to the task
  * @return CronjobSchedule The generated schedule object.
  */
 public function schedulePeriodic($minute = null, $hour = null, $day = null, $month = null, $day_of_week = null, $priority = CronjobSchedule::PRIORITY_NORMAL, $parameters = array())
 {
     return CronjobScheduler::schedulePeriodic($this->id, $minute, $hour, $day, $month, $day_of_week, $priority, $parameters);
 }
Example #3
0
<?php 
/**
 * cronjob-worker - Worker process for the cronjobs
 *
 * @author      Jan-Hendrik Willms <*****@*****.**>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 * @since       2.4
 */
// +---------------------------------------------------------------------------+
// This file is part of Stud.IP
// cronjob-worker.php
//
// Copyright (C) 2013 Jan-Hendrik Willms <*****@*****.**>
// +---------------------------------------------------------------------------+
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or any later version.
// +---------------------------------------------------------------------------+
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// +---------------------------------------------------------------------------+
require_once 'studip_cli_env.inc.php';
CronjobScheduler::getInstance()->run();
 public function down()
 {
     $task_id = CronjobTask::findOneByFilename($this->getFilename())->task_id;
     CronjobScheduler::unregisterTask($task_id);
 }
Example #5
0
 /**
  * Unregisters a previously registered task.
  *
  * @param String $task_id Id of the task to be unregistered
  * @return CronjobScheduler to allow chaining
  * @throws InvalidArgumentException when no task with the given id exists
  */
 public static function unregister()
 {
     $class_name = get_called_class();
     $task = CronjobTask::findOneByClass($class_name);
     if ($task !== null) {
         CronjobScheduler::getInstance()->unregisterTask($task->id);
     }
 }