Report this

What is the reason for this report?

Strange behavior with cron and laravel scheduler

Posted on September 29, 2018

Hello, I have configured a cron job with plesk in my droplet to run a laravel command every minute /opt/plesk/php/7.1/bin/php /var/www/vhosts/website/laravel/artisan schedule:run This executes the Laravel scheduler, that is filled with tasks to run at certain time, lets say send emails at 10:00 and send SMS at 11:00

So when the cron runs the scheduler and a task is found at the same time it executes the task, eg 9.58 no tasks 9.59 no tasks 10:00 send emails 10:01 no tasks

My problem is that FOR SOME STRANGE REASON the scheduler is delayed at some times, so the problem is like this 9.58 no tasks 9.59 no tasks 10:01 no tasks 10:01 no tasks

If I run this command from command line, it runs instantly, with no delay. But for some reason when this is executed from the cron, sometimes is delayed. I have tested the cron from inside plesk, there is a button Run now and is true, for some reason sometimes it takes about 65 seconds to run the cron job or the command artisan schedule:run

Any ideas? This only happens in the droplet I have, not in local environment.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.