Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel artisan cron not working

I have got a page which queues up emails in beanstalked.

The script works as intended, the emails get fired when i have a queue listener, ie.

php artisan queue:listen

But when i remove the listener and add it to the crob job

* * * * * /usr/bin/php /var/www/huge/artisan queue:listen

The emails don't get fired. Any ideas?

like image 252
Swaraj Giri Avatar asked Apr 07 '14 15:04

Swaraj Giri


People also ask

How do I know if cron laravel is working?

Using Output In a Script to Show a Running Cron Job You can add a line of code in your existing script to output a result when the script is run. If the result of this command produces an output, then you can use this output to confirm that your cron script is running.

How scheduler works in laravel?

Laravel's command scheduler offers a fresh approach to managing scheduled tasks on your server. The scheduler allows you to fluently and expressively define your command schedule within your Laravel application itself. When using the scheduler, only a single cron entry is needed on your server.

How do I run a cron job in laravel localhost?

1) You can run php artisan list command in cmd and find your cron. 2) After find your cron, then you can run php artisan yourcron . You can follow this link for more details about cron job. Hope this work for you!


1 Answers

Had this exact same issue the other day, you probably just need to cd in to the directory where Artisan is located first. Try the following:

* * * * * cd /var/www/huge/ && /usr/bin/php artisan queue:listen

Also, are you sure the currently in use PHP CLI is located at /usr/bin and not /usr/local/bin?

If the above doesn't work try:

* * * * * cd /var/www/huge/ && /usr/local/bin/php artisan queue:listen
like image 139
Gareth Daine Avatar answered Sep 29 '22 20:09

Gareth Daine