I wanted to write a long answer with explanation.
1- Crontab is a scheduled job manager. It calls your command every time the scheduler ticks.
eg: If you create a crontab entry to write hello world once in a minute, it will do it every minute, and to the eternity.
2- Queue worker listens to the queue and it works if there is any job awaiting to be done. Very similar to cron jobs, but the execution time is not predefined. See it yourself:
/**
* Listen to the given queue in a loop.
*
* @param string $connectionName
* @param string $queue
* @param \Illuminate\Queue\WorkerOptions $options
* @return void
*/
public function daemon($connectionName, $queue, WorkerOptions $options)
{
// [...]
while (true) {
...
}
}
As you see, she continues until something from the outside world stops her.
4- Your scheduler will create one more worker like this every minute.
Use something like supervisor
to watch your workers. And create your worker instances thoughtfully. See supervisor configuration part of laravel documentation.
If you insist to use cron
and queue workers
together, use queue:work --once
to let your worker know when to stop :)