Run scheduler, i.e executes all due jobs at a given time
@param int $time
@param bool $async
@return array List of executed jobs
556973
function run($time=NULL,$async=TRUE) {
        if (!isset($time))
            $time=time();
        $exec=array();
        foreach(array_keys($this->jobs) as $job)
            if ($this->isDue($job,$time))
                $exec[$job]=$this->execute($job,$async);
        return $exec;
    }
935039
def async_do(self, size=10):
        
        if hasattr(self._session, '_async_jobs'):
            logging.info("Executing asynchronous %s jobs found in queue by using %s threads..." % (
                len(self._session._async_jobs), size))
            threaded_requests.map(self._session._async_jobs, size=size)
1166101
public function dispatch(TaskContract $task, array $params = [], bool $async = true, float $timeout = 1)
    {
        $data = ['object' => $task, 'params' => $params];

        return $async ? $this->server->task($data, -1, function (Server $server, int $taskId, $data) use ($task) {
            $task->finish($data);
        }) : $this->server->taskwait($data, $timeout);
    }
941479
private function scheduleTask(TaskInterface $task, array $workload)
    {
        return $this->taskScheduler->createTask($task->getHandlerClass(), $workload)
            ->executeAt($task->getSchedule())
            ->schedule();
    }
610763
public function start($args = null, $scheduler = false)
    {
        if ($args === null) {
            $this->outputTitle($scheduler ? 'Creating the scheduler worker' : 'Creating workers');
        } else {
            $this->runtime = $args;
        }

        if ($scheduler) {
            if ($this->runtime['Scheduler']['enabled'] !== true) {
                $this->output->outputLine('Scheduler Worker is not enabled', 'failure');
                return false;
            }

            if ($this->ResqueStatus->isRunningSchedulerWorker()) {
                $this->output->outputLine('The scheduler worker is already running', 'warning');
                return false;
            }

            $args['type'] = 'scheduler';
        }


        $pidFile = (isset($this->runtime['Fresque']['tmpdir']) ?
                        $this->runtime['Fresque']['tmpdir'] : dirname(__DIR__) . DS . 'tmp' )
                        . DS . str_replace('.', '', microtime(true));
        $count = $this->runtime['Default']['workers'];

        $this->debug('Will start ' . $count . ' workers');

        for ($i = 1; $i <= $count; $i++) {

            $libraryPath = $scheduler ? $this->runtime['Scheduler']['lib'] : $this->runtime['Fresque']['lib'];
            $logFile = $scheduler ? $this->runtime['Scheduler']['log'] : $this->runtime['Log']['filename'];
            $resqueBin = $scheduler ? './bin/resque-scheduler.php' : $this->getResqueBinFile($this->runtime['Fresque']['lib']);

            $libraryPath = rtrim($libraryPath, '/');

            // build environment variables string to be passed to the worker
            $env_vars = "";
            foreach($this->runtime['Env'] as $env_name => $env_value) {
                // if only the name is supplied, we get the value from environment
                if (strlen($env_value) == 0) {
                    $env_value = getenv($env_name);
                }
                $env_vars .= $env_name . '=' . escapeshellarg($env_value) . " \\\n";
            }

            $cmd = 'nohup ' . ($this->runtime['Default']['user'] !== $this->getProcessOwner() ? ('sudo -u '. escapeshellarg($this->runtime['Default']['user'])) : "") . " \\\n".
            'bash -c "cd ' .
            escapeshellarg($libraryPath) . '; ' . " \\\n".
            $env_vars .
            (($this->runtime['Default']['verbose']) ? 'VVERBOSE' : 'VERBOSE') . '=true ' . " \\\n".
            'QUEUE=' . escapeshellarg($this->runtime['Default']['queue']) . " \\\n".
            'PIDFILE=' . escapeshellarg($pidFile) . " \\\n".
            'APP_INCLUDE=' . escapeshellarg($this->runtime['Fresque']['include']) . " \\\n".
            'RESQUE_PHP=' . escapeshellarg($this->runtime['Fresque']['lib'] . DS . 'lib' . DS . 'Resque.php') . " \\\n".
            'INTERVAL=' . escapeshellarg($this->runtime['Default']['interval']) . " \\\n".
            'REDIS_BACKEND=' . escapeshellarg($this->runtime['Redis']['host'] . ':' . $this->runtime['Redis']['port']) . " \\\n".
            'REDIS_DATABASE=' . escapeshellarg($this->runtime['Redis']['database']) . " \\\n".
            'REDIS_NAMESPACE=' . escapeshellarg($this->runtime['Redis']['namespace']) . " \\\n".
            'REDIS_PASSWORD=' . escapeshellarg($this->runtime['Redis']['password']) . " \\\n".
            'COUNT=' . 1 . " \\\n".
            'LOGHANDLER=' . escapeshellarg($this->runtime['Log']['handler']) . " \\\n".
            'LOGHANDLERTARGET=' . escapeshellarg($this->runtime['Log']['target']) . " \\\n".
            'php ' . escapeshellarg($resqueBin) . " \\\n";
            $cmd .= ' >> '. escapeshellarg($logFile).' 2>&1" >/dev/null 2>&1 &';

            $this->debug('Starting worker (' . $i . ')');
            $this->debug("Running command :\n\t" . str_replace("\n", "\n\t", $cmd));

            $this->exec($cmd);

            $this->output->outputText($scheduler ? 'Starting scheduler worker ' : 'Starting worker ');

            $success = false;
            $attempt = 7;
            while ($attempt-- > 0) {
                for ($x = 0; $x < 3; $x++) {
                    $this->output->outputText(".", 0);
                    usleep(self::$checkStartedWorkerBufferTime);
                }

                if (false !== $pid = $this->checkStartedWorker($pidFile)) {

                    $success = true;
                    $this->output->outputLine(' Done', 'success');

                    $this->debug('Registering worker #' . $pid . ' to list of active workers');

                    $workerSettings = $this->runtime;
                    $workerSettings['workers'] = 1;
                    if ($scheduler) {
                        $this->ResqueStatus->registerSchedulerWorker($pid);
                    }
                    $this->ResqueStatus->addWorker($pid, $workerSettings);

                    break;
                }
            }

            if (!$success) {
                $this->output->outputLine(' Fail', 'failure');
            }
        }

        if ($args === null) {
            $this->output->outputLine();
        }
    }
725511
public function getAllRunningSchedules($host = null)
    {
        $collection = Mage::getModel('cron/schedule')->getCollection();
        $collection->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_RUNNING);
        if (!is_null($host)) {
            $collection->addFieldToFilter('host', $host);
        }
        return $collection;
    }
993932
public function runInForeground(DateTime $now = null) : array
    {
        $jobs = $this->getDueJobs($now);

        $outputs = [];

        foreach ($jobs as $job) {
            $outputs[] = $job->runInForeground();
        }

        return $outputs;
    }
159496
public function getJobsFor(\DateTime $dateTime, $lock = true)
    {
        $dateTime->setTime($dateTime->format("H"), $dateTime->format("i"), 0);
        $serializedJobs = $this->backend->getJobsFor($dateTime, $lock);
        $jobs = array();
        foreach ($serializedJobs as $job) {
            $jobs[] = $this->deserializeJob($job);
        }
        return $jobs;
    }
243380
def run(self, **kwargs):
        
        if not super().run(**kwargs):
            return

        if kwargs['list']:
            self.log.info('--- List of Scheduler Modules ---')
            for name, scheduler in list(self.scheduler_plugins.items()):
                if self.active_scheduler == name:
                    self.log.info('{} (active)'.format(name))
                else:
                    self.log.info(name)
            self.log.info('--- End list of Scheduler Modules ---')
            return

        scheduler = self.scheduler_plugins[self.active_scheduler]()
        scheduler.execute_scheduler()
97462
public function startAllProcesses($wait = true)
    {
        if (empty($this->groups)) {
            return parent::startAllProcesses($wait);
        }

        $results = [];

        foreach ($this->groups as $group) {
            $results = array_merge($results, parent::startProcessGroup($group, $wait));
        }

        return $results;
    }
1294334
public function run($time) {

		if(empty($this->formats) or empty($this->callbacks)) return false;

		if(!is_array($time)) $time = getdate($time);

		$should_run = false;
		foreach($this->formats as $format) {
			if(!$format->test($time)) continue;
			$should_run = true;
			break;
		}
		if(!$should_run) return false;

		foreach($this->callbacks as $callback) {
			if(!is_callable($callback)) continue;
			call_user_func($callback);
		}

		return true;

	}
582781
public function run($workload, TaskWrapper $task)
    {
        $result = false;
        $this->id = $task->getId();
        $this->name = $task->getName();

        try {
            if (false !== $this->beforeRun($workload, $task)) {
                $result = $this->doRun($workload, $task);

                $this->afterRun($result);
            }
        } catch (\Exception $e) {
            $this->onException($e);
        }

        return $result;
    }
559944
public function perHours(int $hours, $task): ScheduleEvent
    {
        return $this->cron(sprintf('0 */%d * * *', $hours), $task);
    }
790605
public function runQueueJob($event)
    {
        if (!$event->sender->request->isConsoleRequest && !$event->sender->request->isAdmin) {
            // use cache to ensure this will run only every 30min
            $this->getOrSetHasCache(['admin', 'bootstrap', 'queue'], function() {
                $timestamp = Config::get(Config::CONFIG_QUEUE_TIMESTAMP);
                // if last execution has NOT been done previously (maybe trough a cronjob)
                if ((time() - $timestamp) > (60*25)) {
                    Yii::debug('"Fake-Cronjob" queue run execution.');
                    Yii::$app->adminqueue->run(false);
                    Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
                }

                return $timestamp;
            }, 60*30);
        }
    }
41824
public function delay(int $delay, AsyncSchedulerInterface $scheduler = null): Observable
    {
        return $this->lift(function () use ($delay, $scheduler) {
            return new DelayOperator($delay, $scheduler ?: Scheduler::getAsync());
        });
    }
596882
public function schedule($code, $time = null)
    {
        $schedule = Mage::getModel('cron/schedule')/* @var $schedule Aoe_Scheduler_Model_Schedule */
            ->setJobCode($code)
            ->setScheduledReason(Aoe_Scheduler_Model_Schedule::REASON_SCHEDULENOW_API)
            ->schedule($time)
            ->save();
        return $schedule->getData();
    }
891729
public function clock(String $clock = '23:59') : Job
    {
        $match = '[0-9]{1,2}';

        if( ! preg_match('/^'.$match.':'.$match.'$/', $clock) )
        {
            throw new InvalidTimeFormatException('Services', 'crontab:timeFormatError');
        }
        else
        {
            $clockEx  = explode(':', $clock);

            $this->minute($clockEx[1]);
            $this->hour($clockEx[0]);
        }

        return $this;
    }