Posted on Leave a comment

WP-CLI wp doctor Command Why it Might Really Help Your Sites

WP-CLI - wp doctor

What is the wp doctor command in WP-CLI?

wp doctor lets you easily run a series of configurable checks to diagnose what’s ailing with WordPress.

Without wp doctor, your team has to rely on their memory to manually debug problems. With wp doctor, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. It comes with dozens of checks out of the box.

namedescription
autoload-options-sizeWarns when autoloaded options size exceeds the threshold of 900 kb.
constant-savequeries-falsyConfirms expected state of the SAVEQUERIES constant.
constant-wp-debug-falsyConfirms expected state of the WP_DEBUG constant.
core-updateErrors when new WordPress minor release is available; warns for a major release.
core-verify-checksumsVerifies WordPress files against published checksums; errors on failure.
cron-countErrors when there’s an excess of 50 total cron jobs registered.
cron-duplicatesErrors when there’s an excess of 10 duplicate cron jobs registered.
file-evalChecks files on the filesystem for regex pattern eval\(.*base64_decode\(.*.
option-blog-publicConfirms the expected value of the ‘blog_public’ option.
plugin-active-countWarns when there are greater than 80 plugins activated.
plugin-deactivatedWarns when greater than 40% of plugins are deactivated.
plugin-updateWarns when there are plugin updates available.
theme-updateWarns when there are theme updates available.

Which wp doctor commands are the most useful?

wp doctor check --all

This command will run all wp doctor commands at once

wp doctor check autoload-options-size

This command will check if the autoload options size is over 900kb. If you have an autoload options size larger than 2.6MB, it will cause site issues.

wp doctor check cron-count

This command will check if there is more than 50 cron job on a site.

wp doctor cron-duplicates

This command will warn if there are more than 10 duplicate cron job registered on a site.

wp doctor plugin-active-count

This command will warn if there are more than 80 activate plugins on a site.

What custom commands can you run with wp doctor?

You can create your own doctor.yml files. In this example, we want to check that MainWP Child plugin and the Classic Editor plugin are installed and active, but that the Hello Dolly plugin is uninstalled on a site.

The example yml file would look like this.

To run the plugin status yml file, the command would be:

wp doctor check --config=plugin-status.yml --all

This command would show if the two defined plugins are active and if the other plugin was uninstalled.

To create your own custom doctor.yml file, this post has a number of tips.

All of the wp doctor commands used in this post are in this Gist.

In summary, wp doctor has many powerful commands that can be used to find if a site has autoload options which need to be optimized, if they have more than 50 cron jobs setup, or if they have duplicate cron jobs setup.

Get MainWP News and Notifications

Sebastian Moran on Github
Sebastian Moran
Sebastian Moran is a WordPress performance expert and technical liaison for MainWP.
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.