setDescription('Runs tasks that have been queued') ->setHelp('This command waits for and runs queued jobs'); } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Waiting for jobs.'); while(true) { if ($job = app('queue')->shift()) { try { $job->run(); $output->writeln("Completed {$job->id}"); $job->is_complete = true; $job->save(); sleep(1); } catch (Exception $e) { $message = $e->getMessage(); $output->writeln("{$message}"); $job->attempts = $job->attempts + 1; $job->save(); } } } } }