By sylvaticus on
Hello, in a multi-site drupal installation I have uploaded during the time hundred of modules, often just to realize they do not work the way I wanted and therefore they are disabled.
My question is, how can I quickly find which modules are not used by any site so I can physically remove them ?
Is there a drush command that do that?
Comments
drush pm-list | grep -v
drush pm-list | grep -v "Enabled"
will filter out enabled modules from the list
That will only list the
That will only list the modules for your "default" site and not for all sites in a multi-site setup.
I've also not found a nice way to get a per-module overview for all sites.
Did you ever find a solution
Did you ever find a solution for this?
I have a similar big cleanup job to do on a massive multi-site installation, and this would be very handy!
If not I'll post how I approached it once done :)
Website Express - Cardiff Web Design & Web Development
No, I just ended up doing a
No, I just ended up doing a pm-list for each site, and pasting it into a spreadsheet. Far from ideal.
ugly but works
This is hacky and imperfect, but if you run it from the root of your drupal installation, it should produce a list of module directories that you can safely remove. Ideally you could just pipe it to svn or whatever (e.g., "
list-unused-modules.sh | xargs svn del"). That said, I did have trouble when I zapped them all at one go -- some module was inappropriately depending on the existence of another one, so I removed a few at a time until I narrowed it down.list-unused-modules.sh:
Note where you need to insert your mysql root password.
Ugly, I know, but gets the job done.
Something like this should
Something like this should work:
drush pm-list --no-core --status=disabled --pipe | drush pm-uninstallbut for some reason that doesn't do the trick. The below, however, will give you a list of disabled modules.
drush pm-list --status=disabledIf someone knows what I'm doing wrong on the first command, please let me know ;)
--Alec
Tandem
Oh, this fixes my
Oh, this fixes my command:
drush pm-uninstall `drush pm-list --pipe --no-core --status=disabled`Thanks to the drush wizards.
--Alec
Tandem
Small Drush command to check the usage of a given module
I was looking for a similar solution and could not find anything that could be used on a Windows workstation, so I wrote a small Drush command that checks if a site uses a certain module. It only works module-by-module and reports sites that use a given module.
To use the Drush command:
is_module_usedin your Drush command folder (on my W7 workstation the location isUSERNAME/.drush);is_module_used.drush.incand copy + paste the script underneath;drush @sites is-module-used -y --pm=NAME_OF_YOUR_MODULE.The script now iterates through all sites and checks per site in the database in the system table 1) if a record for the module exists and 2) if the value of
schema_versionis not -1. This way site names wil be output if they use the module (module is enabled or needs to be uninstalled). If no site names appear, the module is unused and can be safely removed.Laurens Meurs
wiedes.nl
Perfect
@lmeurs Thank you for posting this.
A little grepping?!
This lists all modules (NOT packages) which are not installed across all the sites in a multisite:
Change the '6' at the end to however many sites you're running.
the challenge now is to to find entire packages which are not enabled ;-)
There is a module just for doing that
but sorry I haven't tried this in a multi-site environment.
https://www.drupal.org/project/unused_modules
Have a good day! ;)