/** * Fire the command * * @return void * @author Dan Cox */ public function fire() { $name = $this->input->getArgument('name'); $cmd = $this->input->getOption('cmd'); $commandList = $this->input->getOption('commandlist'); $time = $this->input->getOption('time'); if (Cron::exists($name, 'name')) { $cron = Cron::db()->first(['name' => $name]); if (!empty($cmd)) { $cron->job = $cmd; $cron->command = NULL; } elseif (!empty($commandList)) { if (Command::exists($commandList, 'name')) { $cron->job = NULL; $cron->command = $commandList; } else { throw new \RuntimeException("Command list does not exist"); } } // Update the time if its set if (!empty($time)) { $cron->jobdate = $time; } $cron->save(); $this->output->writeln('Saved updates to cron'); return; } throw new \RuntimeException("The cron you specified does not exist"); }
/** * Updates the crontab file from the database cron jobs * * @return void * @author Dan Cox */ public function updateFromDB() { $crons = CronModel::db()->get(); $file = ''; foreach ($crons as $cron) { $file .= $cron->jobdate . " /usr/bin/php " . ROOT . "alice cron:run " . $cron->id . "\n"; } $this->writeTo($file); }
/** * Fire command * * @return void * @author Dan Cox */ public function fire() { if (Cron::exists($this->input->getArgument('cronid'))) { $this->cron = Cron::db()->find($this->input->getArgument('cronid')); if (!is_null($this->cron->job)) { $this->runCronFromJob(); } else { $this->runCronFromCommandList(); } return true; } throw new \RuntimeException('The cron specified does not exist'); }
/** * Fire the command * * @return void * @author Dan Cox */ public function fire() { $name = $this->input->getArgument('name'); if (Cron::exists([$name, 'name'])) { $cron = Cron::db()->first(['name', $name]); $cron->delete(); // Rebuild the crons $this->get('cron')->updateFromDB(); $this->output->writeln('Removed and updated cron list'); return; } throw new \RuntimeException('The cron you specified does not exist'); }