I have a schedule like this:
<?php
namespace App\Console;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Console\Scheduling\Schedule;
protected function schedule(Schedule $schedule)
{
Artisan::call('queue:work');
}
I add this on my cronjob:
* * * * * cd /var/www/html/my_script_address && php artisan schedule:run
Is it correct code? I am asking, because every minute run Artisan::call('queue:work')
.
Is it the best way?
Your queue worker should be running on its own. You should use supervisor to make sure it stays running. However, if you must start the queue worker from the scheduler it is probably best to use queue:work --stop-when-empty