Posted by grobot on October 16, 2009 at 12:59am
| Project: | Drush |
| Version: | All-versions-5.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
Providing access to a specific module's hook_cron() decouples those modules which we'd like to run frequently (eg checking mail and rss) and those which are intensive.
Drupal provides only a single interval to run all cron hooks at. With this patch, Drush allows the admin to run specific module hooks at specific times, eg triggering mailhandler every five minutes (for groups / discussion sites) while firing session cleanup at 4am daily only.
This can probably be done already by calling drush eval, but then ... what can't?
Comments
#1
#2
This semaphore stuff is messy. The 5 minute cron will block the regular cron, and vice versa. For D7, I think this can be solved with #578676: Use queue for cron. Until then, drush eval or drush script are your friends.
#3
You can also roll your own cron script that handles semaphors per module. That's the approach we take on our sites.
#4
For anyone that happens to come across this, here's how I am eval'ing my own cron hook.
1) Find the appropriate hook_cron call in your module. modulename_cron is what you want.
2) Figure out if any specific variables impact when it is run. In my case, there is a variable modulename_cron_last which tracks the last time the cron was run. I have to force this to 0 to get it to run.
3) Run drush:
drush eval "variable_set('modulename_cron_last', 0);"drush eval "modulename_cron();"
drush eval "variable_set('modulename_cron_last', time());"
4) Make a script and add it to your scheduler (in my case, the actual local Linux crontab)
#5
maybe add drush integration for elysia cron? probably not a feature for core drush cron.
#6
I'm fine with it either way, eval works fine for me. I just did the research on how to run it in case other people came across this thread :)