Hello,
I am developing a module which requires frequent cron runs than other modules. In other words, I must be able to configure module wise cron run frequency. For example: What if search indexing cron has to run everyday but update checking cron only once in a week?
AFAIK drupal invokes all cron hooks whenever cron.php is run. Clearly there is a need to provide module wise cron scheduling customization interface to users.
To provide above feature I have created a simple patch (attached). It would be great if someone can review the code and comment on its usability.
Patch simply gives an interface to user ( at admin/settings/cron-sched) to configure module specific crons in multiple of system cron run ie. run this at each cron run, run that at every fourth cron etc. If there are some inter-dependency of crons then that also can be accommodated. Please ask if you need any further information.
Nitin
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | issue-246380-6.patch | 5.83 KB | lilou |
| cron_patch.patch | 5.61 KB | nitinksingh |
Comments
Comment #1
nitinksingh commentedI should have mentioned how it works. Here it goes..
Now whenever system cron runs ie. drupal_cron_run() is invoked it builds list of modules which has implemented cron hook instead of invoking
module_invoke_all('cron'). While iterating the list it fetches cron_freq_module param and checks whether this cron_hook has to be invoked or not. It invokes the hook, if condition is satisfiedFinally it increases the cron_counter by 1 OR resets to 1 if it is crossing cron_max_count (LCM).
Nitin
Comment #2
mattconnolly commentedI wouldn't bother with the maximum count (LCM) since the modulus operator % will keep every task running at each Nth execution.
Alternatively, you could keep a list of each frequency value, and if they all % to 0 the reset the counter to 0.
Let us know how the module is coming along. :)
Comment #3
Susurrus commentedfeature requests should start in 7.x now and then be backported.
Comment #4
moshe weitzman commentedfyi, a more ambitious patch which has gone a bit stale: #87528: Multi-Threaded Cron Jobs
Comment #5
nitinksingh commentedThanks!!
I'll look into that. :)
Comment #6
lilou commentedReroll patch against CVS/HEAD + coder style.
Comment #7
keith.smith commentedI didn't apply this patch, or test it in situ, but with a read-through, it needs a good bit of work, both on substance and coding style.
There are a lot of issues in the one string I've pasted above, for instance.
Comment #8
lilou commented#87528: Multi-Threaded Cron Jobs is a better approach.