components->error('This command is only available on Linux systems.'); return self::FAILURE; } $crontab = new CrontabRepository(new CrontabAdapter()); $this->components->info('Trying to install Koel scheduler…'); if (self::schedulerInstalled($crontab)) { $this->components->info('Koel scheduler is already installed. Skipping…'); return self::SUCCESS; } $job = CrontabJob::createFromCrontabLine( '* * * * * cd ' . base_path() . ' && php artisan schedule:run >> /dev/null 2>&1' ); $crontab->addJob($job); $crontab->persist(); $this->components->info('Koel scheduler installed successfully.'); return self::SUCCESS; } public static function schedulerInstalled(CrontabRepository $crontab): bool { return (bool) $crontab->findJobByRegex('/artisan schedule:run/'); } }