Laravel 5: non-overlapping schedule

I am trying to schedule laravel to run every minute without overlapping, following the docs: http://laravel.com/docs/5.0/artisan

When I run $schedule->call('Cron::myjob');, it works fine and fires every minute,

When I try to change it so that it never overlaps: $schedule->call('Cron::myjob')->name('job-name')->withoutOverlapping();it fires once and never again.

What am I doing wrong? My team uses a “return” to send the action back to the task, so it should know that it is complete.

EDIT: I found a problem. It seems that the first time I executed the command, I did not “return” the action, so it never ran the command again. I chose a new job name and ran the command again and everything works

+4
source share
1 answer

To prevent overlapping, Laravel uses files with a name "schedule-xxxxxx"where xxxxxx is a hash of a command that should not overlap with itself. Files are hosted in storage/framework. If something goes wrong during the execution of the command, the file cannot be deleted, as a result of which the command will not work again.

What OP did - renaming a command is one solution. A bit easier - deleting mutex files:

rm storage/framework/schedule-*

But none of them is a real solution, if you are not 100% sure that the team will work correctly from now on. Otherwise, the problem may recur soon.

I ended up doing something similar in my cron file:

find /var/www/storage/framework/ -name schedule-5b904de82f094302106f83418c5adb01 -mmin +20 | xargs -I{} rm {}

, . 5 . , 20 , , - , .

, , , , , -. , , , - , , . , . , .

+6

All Articles