Is it possible to run drush cron over a single module, something similar to "drush cron my_module"?


You can do

drush php-eval 'my_module_cron();'

and it should run.

  • What is my_module_cron(); in this context? – Randell Mar 28 '14 at 1:03
  • @Randell If would be the custom hook_cron() that you have defined in my_module. – mpdonadio Mar 28 '14 at 1:05
  • Thanks @MPD! Can I replace it with 'some_nonhook_function()' if I'm using Elysia cron? – Randell Mar 28 '14 at 1:09
  • @Randell You can use php-eval to call / execute anything. I do it all the time to test things. – mpdonadio Mar 28 '14 at 3:12
  • Note though that whatever function you call may not have the proper variables in scope if it's not a cron function. I think hook_cron() implementations, on the other hand, should be self-contained. – Evan Donovan Dec 8 '16 at 18:23

I think you can just use,

drush cron module_name
  • 1
    Can you confirm which version of drush this works in? I just looked at core.drush.inc in the version from PEAR, and I am not seeing arguments for that command. – mpdonadio Oct 4 '12 at 12:55
  • My version reads 5.1 – Selvam Oct 5 '12 at 17:18
  • 2
    It doesn't work with an argument module_name. – Елин Й. Sep 19 '13 at 14:06

You can implement your own drush commands. Have look at the sandwich example code in the drush source package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.