Answer the question
In order to leave comments, you need to log in
Why is the Laravel task scheduler heavy on CPU?
Hello!
Commands are executed using the Laravel task scheduler (App\Console\Kernel.php).
protected function schedule(Schedule $schedule)
{
$schedule->command('Cron --method=clear')->runInBackground()->everyMinute();
$schedule->command('Cron --method=getData')->runInBackground()->everyMinute();
...
}
Answer the question
In order to leave comments, you need to log in
1. Laravel does not have any special scheduler, cron is used.
2. Every minute you run unknown doing tasks. Maybe you're counting a trillion digits of pi there.
3. There are no seers and soothsayers here.
PS Commands that launch controller methods are terrible.
See how hard this task is in itself without cron and what it does. Maybe there is some kind of resource lock, database, etc.
In itself, raising php, parsing and executing a script is a rather resource-intensive thing. If this needs to be done every minute, it might be worth writing a sleep daemon.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question