Load the cron jobs that should be runned and register them into the
jobs array.
975237
public function addJob($job = []) {
        if(!isset($job['msg']))
            throw new RuntimeException('Job without a message');

        if(!isset($job['schedule']))
            throw new RuntimeException('Job without a CRON expression');

        if(!isset($job['function']))
            throw new RuntimeException('Job without a function');

        if($this->isDue($job['schedule']))
            $this->jobs[] = $job;
    }
582430
def ReadCronJobRun(self, job_id, run_id):
    """"""
    for run in itervalues(self.cronjob_runs):
      if run.cron_job_id == job_id and run.run_id == run_id:
        return run
    raise db.UnknownCronJobRunError(
        "Run with job id %s and run id %s not found." % (job_id, run_id))
1130067
public function registerEvents()
    {
        $job = & $this->job;

        Event::listen(Event::JOB_PERFORM, function ($event, $_job) use (&$job) {
            $job = $_job;
        });
    }
60105
public void reloadJobs() {

        m_beanContainer.removeAllItems();
        for (CmsScheduledJobInfo job : m_manager.getAllElements()) {
            m_beanContainer.addBean(new CmsJobBean(job));
        }
        sort();
        refreshRowCache();

    }
118603
def Start(self):
    """"""
    cron_jobs_ttl = config.CONFIG["DataRetention.cron_jobs_flows_ttl"]
    if not cron_jobs_ttl:
      self.Log("TTL not set - nothing to do...")
      return

    manager = aff4_cronjobs.GetCronManager()
    cutoff_timestamp = rdfvalue.RDFDatetime.Now() - cron_jobs_ttl
    if data_store.RelationalDBEnabled():
      deletion_count = manager.DeleteOldRuns(cutoff_timestamp=cutoff_timestamp)

    else:
      deletion_count = 0
      for job in manager.ReadJobs(token=self.token):
        deletion_count += manager.DeleteOldRuns(
            job, cutoff_timestamp=cutoff_timestamp, token=self.token)
        self.HeartBeat()

    self.Log("Deleted %d cron job runs." % deletion_count)
997066
def _jobs():
    '''
    
    '''
    response = salt.utils.http.query(
        "{0}/scheduler/jobs".format(_base_url()),
        decode_type='json',
        decode=True,
    )
    jobs = {}
    for job in response['dict']:
        jobs[job.pop('name')] = job
    return jobs
975218
def ReturnLeasedCronJobs(self, jobs, cursor=None):
    """"""
    if not jobs:
      return

    unleased_jobs = []

    conditions = []
    args = []
    for job in jobs:
      if not job.leased_by or not job.leased_until:
        unleased_jobs.append(job)
        continue

      conditions.append("""
      (job_id = %s AND leased_until = FROM_UNIXTIME(%s) AND leased_by = %s)
      """)
      args += [
          job.cron_job_id,
          mysql_utils.RDFDatetimeToTimestamp(job.leased_until), job.leased_by
      ]

    if conditions:
      query = ("UPDATE cron_jobs "
               "SET leased_until=NULL, leased_by=NULL "
               "WHERE ") + " OR ".join(conditions)
      returned = cursor.execute(query, args)

    if unleased_jobs:
      raise ValueError("CronJobs to return are not leased: %s" % unleased_jobs)
    if returned != len(jobs):
      raise ValueError("%d cronjobs in %s could not be returned." %
                       ((len(jobs) - returned), jobs))
926136
private void scheduleGeneralConfiguredJobs()
      throws ConfigurationException, JobException, IOException {
    LOG.info("Scheduling configured jobs");
    for (Properties jobProps : loadGeneralJobConfigs()) {

      if (!jobProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) {
        // A job without a cron schedule is considered a one-time job
        jobProps.setProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "true");
      }

      boolean runOnce = Boolean.valueOf(jobProps.getProperty(ConfigurationKeys.JOB_RUN_ONCE_KEY, "false"));
      scheduleJob(jobProps, runOnce ? new RunOnceJobListener() : new EmailNotificationJobListener());
      this.listener.addToJobNameMap(jobProps);
    }
  }
400932
protected function job(): void
    {
        while (true) {

            $logs = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($logs->isCachedLoad()) return;

            collect($logs)->each(function ($log) {

                CorporationContainerLog::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'container_id'   => $log->container_id,
                    'logged_at'      => carbon($log->logged_at),
                ])->fill([
                    'container_type_id'  => $log->container_type_id,
                    'character_id'       => $log->character_id,
                    'location_id'        => $log->location_id,
                    'action'             => $log->action,
                    'location_flag'      => $log->location_flag,
                    'password_type'      => $log->password_type ?? null,
                    'type_id'            => $log->type_id ?? null,
                    'quantity'           => $log->quantity ?? null,
                    'old_config_bitmask' => $log->old_config_bitmask ?? null,
                    'new_config_bitmask' => $log->new_config_bitmask ?? null,
                ])->save();

            });

            if (! $this->nextPage($logs->pages))
                break;
        }
    }
422690
public function scheduleWork()
    {
        if (is_null($this->scheduler)) {
            return;
        }

        $this->scheduler->reconnect();

        foreach ($this->scheduler->getJobsFor(new \DateTime()) as $job) {
            $this->pipeline->enqueue($job);
        }
    }
321830
protected function loadSchedules()
    {
        /* @var Mage_Cron_Model_Resource_Schedule_Collection $collection */
        $collection = Mage::getModel('cron/schedule')->getCollection();

        $minDate = null;
        $maxDate = null;

        foreach ($collection as $schedule) {
            /* @var Aoe_Scheduler_Model_Schedule $schedule */
            $startTime = $schedule->getStarttime();
            if (empty($startTime)) {
                continue;
            }
            $minDate = is_null($minDate) ? $startTime : min($minDate, $startTime);
            $maxDate = is_null($maxDate) ? $startTime : max($maxDate, $startTime);
            $this->schedules[$schedule->getJobCode()][] = $schedule;
        }

        $this->starttime = $this->hourFloor(strtotime($minDate));
        $this->endtime = $this->hourCeil(strtotime($maxDate));
    }
1241102
def schedule_jobs(jobs)
      scheduler = Rufus::Scheduler.start_new

      jobs.each do |job|
        if job['cron']
          Mongolicious.logger.info("Scheduled new job for #{job['db'].split('/').last} with cron:  #{job['cron']}")
          scheduler.cron job['cron'] do
            backup(job)
          end
        else
          scheduler.every job['interval'] do
            Mongolicious.logger.info("Scheduled new job for #{job['db'].split('/').last} with interval: #{job['interval']}")
            backup(job)
          end
        end
      end

      scheduler.join
    end
56273
def _register_jobs(self):
        

        # job_name is hard-corded
        job_name = 'ConcreteJob'
        modules = self._get_modules()

        for section, options in self.config.items():

            if section == 'global':
                continue

            try:
                name = options['module']
            except KeyError:
                raise ConfigMissingValue(section, 'module')

            try:
                job = getattr(modules[name], job_name)
                self.notify(name, job)
            except KeyError:
                raise NotSupportedError(name)
211170
def ReturnLeasedCronJobs(self, jobs):
    """"""
    errored_jobs = []

    for returned_job in jobs:
      existing_lease = self.cronjob_leases.get(returned_job.cron_job_id)
      if existing_lease is None:
        errored_jobs.append(returned_job)
        continue

      if (returned_job.leased_until != existing_lease[0] or
          returned_job.leased_by != existing_lease[1]):
        errored_jobs.append(returned_job)
        continue

      del self.cronjob_leases[returned_job.cron_job_id]

    if errored_jobs:
      raise ValueError("Some jobs could not be returned: %s" %
                       ",".join(job.cron_job_id for job in errored_jobs))
1081164
public function load()
    {
        $this->out('<info>' . __d('cake_resque', 'Loading predefined workers') . '</info>');

        $debug = isset($this->params['debug']) ? $this->params['debug'] : false;
        $queues = Configure::read('CakeResque.Queues');

        if ($queues === null) {
            $this->out('   ' . __d('cake_resque', 'You have no configured workers to load.'));
        } else {
            foreach ($queues as $workerArgs) {
                $workerArgs['debug'] = $debug;
                $this->start($workerArgs);
            }
        }

        if (Configure::read('CakeResque.Scheduler.enabled') === true) {
            $this->startscheduler(['debug' => $debug]);
        }

        $this->out('');
    }
88658
def run_job(self, name):
        '''
        
        '''
        data = self._get_schedule().get(name, {})

        if 'function' in data:
            func = data['function']
        elif 'func' in data:
            func = data['func']
        elif 'fun' in data:
            func = data['fun']
        else:
            func = None
        if not isinstance(func, list):
            func = [func]
        for _func in func:
            if _func not in self.functions:
                log.error(
                    'Invalid function: %s in scheduled job %s.',
                    _func, name
                )

        if 'name' not in data:
            data['name'] = name
        log.info('Running Job: %s', name)

        # Grab run, assume True
        run = data.get('run', True)
        if run:
            self._run_job(_func, data)
105818
def get_jobs():
    """"""

    jobs = current_app.apscheduler.get_jobs()

    job_states = []

    for job in jobs:
        job_states.append(job)

    return jsonify(job_states)