Question
Strange behavior with cron and laravel scheduler
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.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×