phplaravelqueuelaravel-5.3laravel-scheduler

Laravel task scheduler doesn't work


I tried to run scheduler in laravel 5.3 with the following code in App/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
    $schedule->command('queue:work')->everyMinute()->withoutOverlapping();
}

and set cron jobs in my shared hosting with the following:

* * * * * php /home/username/public_html/laravel/artisan schedule:run >> /dev/null 2>&1

but it doesn't work in my shared hosting

I used database driver for my queue, and the attempts still 0, which is the queue is not execute by the task scheduler.

Anyone can help me with this problem?


Solution

  • A few things you might want to check:

    queue:work

    Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal. https://laravel.com/docs/5.3/queues#running-the-queue-worker

    Are you sure you want to spawn a new process with the Scheduler every minute?

    powering scheduler

    artisan schedule:run command needs to be run every minute in order for the Scheduler to work. This might be done with the cron: https://laravel.com/docs/5.3/scheduling#introduction