WordPress offers the possibility to carry out updates automatically. The updates are also carried out during peak hours (during the day). WP-CLI can be used wonderfully to carry out the updates at a defined time.
Another aspect is the translation files of WordPress itself, the plugins and themes are currently not updated automatically by WordPress. Everyone knows that these updates have to be carried out manually in the dashboard on a regular basis. This can also be automated with WP-CLI . If we fail to update, we run the risk of English terms appearing on a non-English page or in the WordPress panel.

In order to automate the updates we need a so-called cron job (at Plesk it is called ” Planned Tasks ” in German and is located under Websites & Domains in the right side menu) with which we run WP-CLI on our WordPress installation. Cronjobs can be used to execute time-controlled commands or call up URLs. Mail notification can also be set up each time it is called up or in the event of an error. The following explanations relate to a Linux hosting which is in> 99% of the time is the case with most. If you are one of the few who have Windows hosting, the steps have to be adjusted a little.
So that WP-CLI can be used, we have to download it and store it in our own web hosting or server. The package contains the executable “wp”. This should now be stored in the file system in web hosting (use either FTP, SFTP or Plesk’s file manager). In order for the file to actually be executed, it requires execution rights. To do this, set the execution rights with the Plesk file manager or FTP program (see Plesk documentation ). Now we are ready to create the planned task.

In Linux command line shells, in which the execution of the cron jobs takes place, there is the possibility to chain commands. With && commands are chained and executed in the order from left to right (e.g. Command1 && Command2 –MyParameters etc.). The operator & can also be used instead of &&. Then the following commands will only be executed if the previous command has run through successfully. In this case, it doesn’t make a big difference which operator we use for our automatic updates.
So that everything is really updated incl. of the translation files we use the following command:
cd /wordPressInstallation && wp core update && wp plugin update – all && wp theme update – all && wp language core update && wp language plugin update – all && wp language theme update – all
First we change to the WordPress installation directory with cd / wordPressInstallation (the WordPress installation is often located under / httpdocs ). If there are several WordPress instances, a planned task can be created for each page and the steps are repeated for each appearance. Then the update (or update check) of WordPress itself is initiated via wp core update and the update of all plugins and themes is started via wp plugin update –all and wp theme update –all . Here you can also restrict which plugins / themes the updates should be carried out for or which should be ignored.
The most interesting point is the wp language command. This allows the said translation files to be updated. This can be done accordingly for core (WordPress itself), plugins and themes.
So that wp can be used as a command, the path to the directory in which the executable file wp is located must be contained in the so-called PATH variable. To do this, add the following line to the .profile file (create file if necessary) in the main directory of the hosting:
PATH=/mybin:$PATH
/ mybin must be replaced accordingly by the path in which wp is located. Alternatively, the absolute path can be used in the cron jobs instead of wp , e.g. / mybin / wp core update . Then the extension of the PATH variable is not necessary.
Update WP-CLI regularly
So that WP-CLI is always up-to-date and therefore compatible with the current WordPress version, it must also be updated regularly. Smart with the following command.
wp cli update
We also create a planned task for this purpose. I run it in my customer hostings once a month. That is completely sufficient for the update frequency of WP-CLI.