Bolt\Cron::execute PHP Method

execute() public method

Run the jobs.
public execute ( array $param = [] ) : boolean
$param array
return boolean
    public function execute($param = [])
    {
        $this->param = $param;
        $this->runtime = new \DateTime();
        // Get schedules
        $this->getRunTimes();
        // Time of day for daily, weekly, monthly and yearly jobs
        $this->getScheduleThreshold();
        $event = new CronEvent($this->app, $this->output);
        // Process event listeners
        foreach ($this->jobs as $name => $data) {
            $this->executeSingle($event, $name, $data);
        }
        return true;
    }

Usage Example

Example #1
0
 /**
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('run')) {
         $event = $input->getOption('run');
         $param = ['run' => true, 'event' => $event];
     } else {
         $event = false;
         $param = ['run' => false, 'event' => ''];
     }
     $result = new Cron($this->app, $output);
     if ($result->execute($param)) {
         if ($event) {
             $this->auditLog(__CLASS__, "Cron {$event} job run");
         } else {
             $this->auditLog(__CLASS__, 'Cron run');
         }
         $output->writeln('<info>Cron run!</info>');
     }
 }