All Collections
Advanced CMS Support
WordPress
Upgrade all WordPress installs via SSH
Upgrade all WordPress installs via SSH

Use wp-cli to upgrade ALL WordPress installs via SSH

Justin Catello avatar
Written by Justin Catello
Updated over a week ago

Below you will find a few commands to run that can find and upgrade all WordPress installs on your server.
One thing to note is, we use wp-cli: http://wp-cli.org/
This can only upgrade installs above version 3.7 which should hopefully not be the case but you can upgrade it using wp-cli still manually if needed, Ill show how at the end.

1. Log into SSH
2. cd into the folder of the location where the installs reside.

# cd /home/user

3. Next we will download wp-cli and set its location:

rm -f wp-cli.phar 
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
wpcli=$(pwd)/wp-cli.phar

4. Make sure to run this from the same initial location you cd'd into:

for wpinstall in $(find $(pwd)/ -type f -name wp-config.php | sed 's/wp-config.php//g') ; do echo Checking $wpinstall ... ; cd $wpinstall ; $wpcli core check-update --skip-plugins --skip-themes ; sleep 2 ; $wpcli core update --skip-plugins --skip-themes ; $wpcli core update-db --skip-plugins --skip-themes ; done

Example output:

# for wpinstall in $(find $(pwd)/ -type f -name wp-config.php | sed 's/wp-config.php//g') ; do echo Checking $wpinstall ... ; cd $wpinstall ; $wpcli core check-update --skip-plugins --skip-themes ; sleep 2 ; $wpcli core update --skip-plugins --skip-themes ; $wpcli core update-db --skip-plugins --skip-themes ; done

Checking /home/user/public_html/blog/ ...
Success: WordPress is at the latest version.
Success: WordPress is up to date.
Success: WordPress database upgraded successfully from db version 18226 to 38590.

Checking /home/user/public_html/domain.com/eb/ ...
Success: WordPress is at the latest version.
Success: WordPress is up to date.
Success: WordPress database upgraded successfully from db version 22441 to 38590.

Checking /home/user/public_html/domain.net/ ...
Updating to version 4.7.3 (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-4.7.3-new-bundled.zip...
Unpacking the update...
Cleaning up files...
No files found that need cleaned up.
Success: WordPress updated successfully.
Success: WordPress database upgraded successfully from db version 27918 to 38590.

Checking /home/user/public_html/partners/ ...
Success: WordPress is at the latest version.
Success: WordPress is up to date.
Success: WordPress database upgraded successfully from db version 21707 to 38590.
Did this answer your question?