i am using laravel scheduler to run my tasks. For everyone info there is no issue with cron or schedular function/commadn.
The issue is i have run command with withoutOverlap method on schedualr. and that command some how go into memory error that is resolved. but the isseu is due to overlap method my command is in lock state.
i search online they say go to storage/framework. there u will find schedule-******* something like this but i dint have any file like that i am using laravel 8.
please i need help. i dont want my commadn to overlap so i need that functionality badly
The scheduler creates what is called a mutex record in cache when the task starts and then clears it when the task ends. If the task crashes then the mutex file remains.
If needed, you may specify how many minutes must pass before the "without overlapping" lock expires. By default, the lock will expire after 24 hours:
@BroJenuel Yes. If you don't pass any value to withoutOverlapping, it will create a 24h mutex. The command will be skipped for 24h, but run again after that even if it's still running.
if the command finishes within 15 minutes, the mutex already expired so it will not run again.
or does it mean
the command will run every thirty mins.
mutex gets created for 1 minute
mutex expires after 1 minute and will run the cached command. so now i have the command that started a minute ago running, and the mutex command running a minute later
@JeffH no, both conditions need to pass to run the command. The mutex stops the command from running as long as it has not been removed (by the same command finishing) or has expired.
In your case, when attempting to run the command after 30 min you have no idea if the previous command has finished or is still running, as there would be no mutex either way.
I don't see what expiring the mutex before the next command would run achieves.
@krisi_gjika My goal is to run test-command every 15 minutes unless it is still running from the previous attempt. In which case i want to ignore the next run.
For example
3:00pm test command runs
3:05pm test command ends
3:15pm test command runs again (lets call this CommandA)
3:30pm CommandA is still running. Do not run test-command again
@JeffH yes, by just chaining ->withoutOverlapping() to your command it will work like that. However if the command at 3:30pm crashes and is not able to clear its mutex it will not run again at 3:45pm as it's mutex has not yet expired. It is up to you to decide what is a reasonable about of time to wait for your command, or make sure you handle any exceptions that your command might throw.