I have problem to run artisan queue:work
command using task scheduling in laravel 5.3
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel {
protected $commands = [];
\Log::info('schedule:run');
protected function schedule(Schedule $schedule)
{
$schedule->command('queue:work --tries=3')
->everyMinute()
->withoutOverlapping()
->evenInMaintenanceMode()
->sendOutputTo(storage_path() . '/queue-logs/queue-jobs.log', true);
}
}
* * * * * /usr/local/bin/php /home/s***app/public_html/artisan schedule:run
I got log in \\Log::info('schedule:run');
in /queue-logs/queue-jobs.log
file every minutes. But command queue:work --tries=3
not work and queue stored in job table not processed.
And also my hosting provider block my every minutes request and suggest me to run this cron to 15 min instead of 1 minute
I was experiencing the same issue in Laravel 5.7, using Ubuntu 16.04: My jobs in the job table were being queued but not being executed:
This is what I did:
Ssh to your server ie ssh username@ip
Then run sudo nano /etc/crontab
Add the following line inside the file * * * * * username php /var/www/your_laravel_project/artisan schedule:run >> /dev/null 2>&1
Make sure you do not forget this part here: /artisan
after your project folder. I was doing this mistake and my cron was not running.
Explanation:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * user-name command-to-be-executed
Then run sudo systemctl restart cron
to restart the cron service.
You can also check it's status using sudo systemctl status cron
Tip: It would be better if you do not use shared hosting to since many shared hosting services won't allow you to run crons every minute. Digital Ocean has droplet packages for as low as $20 per month. Consider setting up your own server using Digital Ocean, AWS etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.