-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crons are not being executed. #11
Comments
I'm forcing the job to run in foreground because I am creating a lock file and deleting it after the scheduled script is being executed. If I run the job in background I won't have a way to remove the lock file and the next cron job will never run until you manually delete the lock file. That was the solution I found when I developed that feature, but if you have a better idea we can discuss it. About the second issue you're absolutely right and I'm happy to merge the changes. Thanks! |
Hello @peppeocchi, I have posted the issue by mistake from the company account. It doesn't matter if you are running the script in foreground or background because in both cases you are removing the lock file with
The test above confirms that it's safe to modify your
|
@csaba-meszaros you're right, there is no need to force the job to run in foreground. I'll remove that line, thanks! |
* Lock files now contain the command they lock. * Made verbose lock files an opt-in config flag. * Added missing \ in PHPDoc param definition * Added doNotOverlap() support for anonymous closures. * All tests now clean up /tests/tmp when finished. * Job::isDue() now takes into account the time that was, when schedule was triggered. #11 * Remove lock file after closure execution * Make tests pass
It took me some time to debug this issue.
We are using your script to schedule raw commands using CronExpressions like
->at("0 3 * * *")
. Some of our commands are with doNotOverlap() others are not. We have a total of 20 commands scheduled.I have observed that when doNotOverlap() is set you, always set the job to run in foreground even if I haven't set the explicitly on the job.
The problem is that the CronExpression
isDue()
calculates the execution time always using strtotime("now"). Because the execution could take more than one minute and it runs in foreground, the next job picked from the list won't be executed because the isDue will return false, it's not on time anymore because isDue will use now() and not the time the job was scheduled.Solutions:
1.) I don't understand why you force nonOverlapping jobs to run in foreground. You should remove that line because it doesn't make much sense to me.
2.) You should rewrite your isDue function to use the time when the job was scheduled and not current time which could be several minutes later because of the non-overlapping jobs.
I think both 1.) and 2.) solutions should be applied on your script.
The text was updated successfully, but these errors were encountered: