Question

I want to run some maintenance scripts against a Drupal 7 system. These scripts will call the Drupal API to use things like EntityFieldQuery, node->save and so on. I could create a module called maintenance_scripts which has a forms interface to launch the scripts with and to display their output, but I'd rather just run a script from the command line. Is this possible?

Was it helpful?

Solution

It is not necessary to write an entire Drush command just to run some php code. Use:

drush php-eval '$a = callSomeFunction(); print $a;'

or:

drush php-script /path/to/script.php

Drush will bootstrap your site and run your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top