I have recently set up a new hosting space at O2switch all run as usual with 1 cpanel main and 4 extra if you want to compartmentalize for security.
I am very impressed by the quality-price ratio of O2switch, they make the deployment of the sites if easy and in addition, you have an SSH access to good practice, as I decided to use wp-cli.
As shown in the vulnerability of the REST APIit really is crucial to keep abreast of the updates.
I currently use a management system called Mainwpbut I decided to use WP CLI to have more scalability and save time (yes, you can manage mainwp with wp-cli 😉 ).
The Main commands
There are four basic commands to stay abreast of the updates :
wp core check-update
wp core update
wp plugin list
wp plugin update --all
They explained themselves and let you know if there are any updates available and apply them.
Connect to a server, navigate in the Web directory and potentially run four commands is not exactly a time saver.
Especially when you have to do it on a daily basis to ensure that fixes are applied as soon as possible.
Fortunately, we can easily automate it with a simple bash script in few essential steps :
- find all the WordPress installations and the loop on it
- browse their directory
- run the two commands in WP-CLI required to verify updates of core and plugins
Once the basics are working, the script can be easily extended with options such as the choice between check for updates or do updates.
The standard way to find a WordPress install to be able to use WP CLI is to search for the files wp-config.php since you can be sure that they exist.
Then navigate to the directory where you found it, and run the command.
There are many ways to extend or customize it – but this summary covers the basics and should be flexible enough to cover all configurations :
The last piece of the puzzle is to combine the script with cron, and mail.
Instead of connecting each day to run the script and check for updates, we can use cron to run it and send the result by e-mail.
This means that I can wait for the server to tell me when I need to connect and run an update, without having to constantly check.
Article inspiré par bnks.xyz