15

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

4 Answers 4

26

You can do

drush php-eval 'my_module_cron();'

and it should run.

5
  • What is my_module_cron(); in this context?
    – Randell
    Mar 28, 2014 at 1:03
  • @Randell If would be the custom hook_cron() that you have defined in my_module.
    – mpdonadio
    Mar 28, 2014 at 1:05
  • Thanks @MPD! Can I replace it with 'some_nonhook_function()' if I'm using Elysia cron?
    – Randell
    Mar 28, 2014 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, 2014 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. Dec 8, 2016 at 18:23
0

If you install the contrib project Ultimate Cron, you get extra Drush commands including:

drush cron:run my_module

which allows you to run a cron for a specific module.

-1

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

-1

I think you can just use,

drush cron module_name
3
  • 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, 2012 at 12:55
  • My version reads 5.1
    – Selvam
    Oct 5, 2012 at 17:18
  • 4
    It doesn't work with an argument module_name.
    – Elin Y.
    Sep 19, 2013 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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