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

To automate the updates we need a so called cronjob (in Plesk it is called“Scheduled Tasks” in German and can be found 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 URLs. A mail notification can also be set up for each call or in the event of an error. The following explanations refer to a Linux hosting which is found in > 99% of the case with most. If you are one of the few who have Windows hosting, you will have to adjust the steps a bit.
In order to use WP-CLI we need to download it and place it in our own web hosting or server. The package contains the executable file “wp”. It should now be placed in the file system in the web hosting (use either FTP, SFTP or Plesk’s file manager for this). For the file to actually be executed it needs an execute right. To do this, use the Plesk file manager or FTP program to set the execution rights (see Plesk docs). Now we are ready to create the planned task.

In Linux commandline shells, where the execution of cronjobs takes place, there is a possibility to chain commands. With && commands are concatenated and executed in order from left to right (e.g. Command1 && Command2 –MyParameter etc.). You can also use the & operator instead of &&. Then the following commands will be executed only if the previous command has been executed successfully. But in this case it does not make a big difference for our automatic updates which operator we use.
So that really everything is 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 with cd /wordPressInstallation to the WordPress installation directory (often the WordPress installation is located under /httpdocs). If there are multiple WordPress instances, a scheduled task can be created for each site and the steps are repeated for each appearance. After that, wp core update triggers the update (or update check) of WordPress itself and wp plugin update –all and wp theme update –all start the update of all plugins and themes. Here you can also restrict for which plugins/themes the updates should be made or which should be ignored.
The most interesting point is the wp language command. This can be used to update the said translation files. Accordingly, this can be done for Core (WordPress itself), plugins and themes.
In order to use wp as a command, the path to the directory where the wp executable file 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 root directory of the hosting:
PATH=/mybin:$PATH
/mybin must be replaced accordingly with the path where wp is located. Alternatively, the absolute path in the cronjobs can be used instead of wp, e.g. /mybin/wp core update. Then the extension of the PATH variable is not necessary.
Update WP-CLI regularly
In order for WP-CLI to always be up-to-date and thus compatible with the current WordPress version, it must also be updated regularly. The clever with the following command.
wp cli update
For this purpose, we also create a scheduled task. I run it in my customer hostings 1x a month. This is perfectly sufficient for the update frequency of WP-CLI.