Drupal Tip: Finding all instances of Drupal in Linux/Unix

In an environment where Drupal development has been going on for a while and people have been doing the experimentation required to gain familiarity with the platform, it's common for a lot of wayward Drupal installations to accumulate. Add to this a system which hosts numerous Drupal installations anyway (such as a university, large enterprise or a hosting service) and it can become challenging to keep track of them all.

Below is a simple Linux command that can help with this. It's a basic command that finds all instances of the index.php file in a tree and prints out only the ones that contain the string "DRUPAL_BOOTSTRAP_FULL". Since a Drupal installation will always have 1 and only 1 index.php file that contains this string there is a one-to-one correlation between this file and a Drupal instance.

It's a bit rough, but the output from this command can be redirected to other commands or scripts that can give you all kinds of information about the Drupal installations on your system, especially if you incorporate Drush.

I hope you find this useful, and please feel free to let me know if you turn it into anything more slick. My next step with it will be to create a tool that reports on the status of all modules installed across all Drupal installations on the server.

Enjoy! ~ K

find . -name index.php -exec grep -q "DRUPAL_BOOTSTRAP_FULL" '{}' \; -print

The Next Step... DrupalMonitor

I've now taken this concept to it's logical next step... a script that finds all Drupal instances installed under a given tree, then finds all Drupal sites for each instance, and executes some select drush commands for each site. Obviously this can be dangerous so some security concerns and user-interface work is still to be done, so it's not ready to share just yet. More to come! ~ K