简体   繁体   中英

Cron jobs on shared hosting using laravel scheduler not working

I am having issue of running laravel scheduler to send mails in the queue

The setup is as follows: Laravel 5.7 I have configured the scheduler (App/Console/Kernel.php) like mentioned below

protected function schedule(Schedule $schedule)
{       
  $schedule->command('queue:work --tries=3')->everyFiveMinutes()->withoutOverlapping();
}

The db is set-up as per laravel docs. As soon as I click the link in my UI, I can see the entry in the db.

The .env QUEUE_CONNECTION=database and the same setting in Config/queue.php (if i change the database to sync, it works perfectly)

My cron job in the server is as follows ( i just tried to log the cron)

/usr/local/bin/php /home/XXX/YYY/artisan schedule:run 1>> /home/XXX/public_html/junk/cron_log.php 2>&1

I can see the cron logs getting updated every five minues but

"No scheduled commands are ready to run"

Exactly the same code and settings last night worked(before going to bed). I had tested for more than 40 emais send attempts and the db entries were getting deleted. I only tried to save the scheduler with everyFiveMinues() but now it is not working.

I can understand mails reaching slowly but why the db entries were not deleted like last night?

this may be useful to other who are using Laravel 5.7, shared hosting Godaddy.

The above issue of dispatching email jobs was not executing ( I mean the cron jobs are running but database entries are not cleared. The issue seems to be with

->withoutOverlapping();

After I have deleted this method, I am now seeing the cron_log entries correctly and I have also received mails. My cron_log entries are as seen below

Running scheduled command: '/opt/alt/php71/usr/bin/php' 'artisan' queue:work --tries=3 > '/dev/null' 2>&1

I am guessing the method withoutOverlapping() has problem in cron execution. I have not changed anything in the code.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM