-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
Check if cron not running already when triggering another cron #1178
Comments
I'd be interested in a potential solution but I'm a bit wary of adding that complexity by default. Mostly since I don't know what the solution would look like 🤷♂️ |
It would be probably something like: to It would have to be limited to domain and to do that path would have to be one of the params of function. Let me know if that's fine. If yes, I will send a PR. |
I have this same issue. Our cron runs for ages and the next one often starts before the first had finished, causing an overlap. Introducing a cron lock file may be a solution. Note, if using something like a lock file, be sure to check if a cron fails or crashes, the lock file is still deleted eventually else the next cron will never run. Use another cron to check the date/time of the existing lock file, if older than X delete it. Just an idea. I don't have enough experience to build this yet, but I'll try. +1 to this original request. |
Sorry just getting to this. @maciekpaprocki would you still be interesting in submitting a PR?
By "domain", you mean the path to the site right? eg: |
Hey, generally something around solution I gave should work. Maybe some logging added also when that happens. Lock would be maybe nicer, but I am not sure if it gives it much. I might maybe take a look on it one day, but I am not gonna lie, don't have much spare time for open source recently. |
Summary
Make sure that cron is not running already when triggering another cron.
Motivation
The other day I found a peculiar bug in one of the plugins on my website. cron option in DB (wp_options name='cron') had thousands of duplicates of one cron job scheduled. That caused cron to run for hours. When few crons overlapped that made the server run out of resources. Obviously, the solution is to clear the scheduled jobs and fix the plugin, but I think there would be quite a lot of value in making cron check if the previous cron finished running before starting another one ( or even allow certain amount of parallel runs you can adjust yourself ).
I am happy to work on that if other people see the value in it.
The text was updated successfully, but these errors were encountered: