Update your wordpress blog via CLI.

Recently, i try to update my blog via the web,
and it return « timeout » after few minutes.
So i move this task to CLI, more safer !

First, if you crash your last web setup,
Remove the lock into the php :

wp-admin/includes/class-core-upgrader.php

Simply comment this :

if ( ! $lock ) {
#return new WP_Error( 'locked', $this->strings['locked'] );
}

-> Setup is very easy, you have to install wp command, here i’m doing this into my /opt/ :

cd /opt/
wget -c http://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
ln -s /opt/wp-cli.phar /usr/local/bin/wp

Now i’m using this command :

-> Go to your blog root path and simply to :

root@crx-web01 html # cd /myultrasecurepath/bastien.barbe.pw/
root@crx-web01 html # sudo /usr/local/bin/wp core --allow-root update
Updating to version 5.4.2 (fr_FR)...
Téléchargement de la mise à jour depuis https://downloads.wordpress.org/release/fr_FR/wordpress-5.4.2.zip…
Décompression de la mise à jour...
Success: WordPress updated successfully.

#same for plugins/themes : 

sudo /usr/local/bin/wp plugin update --all --allow-root

sudo /usr/local/bin/wp theme update --all --allow-root

 

Sources:
https://blog.microlinux.fr/wp-cli-update/