WordPress command-line-based nightly updater for bash.
WordPress Updater is a simple script to update all the WordPress sites installed on the server. It is able to dynamically discover them and update them in four ways:
- Upgrade WordPress software itself
- Upgrade the WordPress database version
- Upgrade any installed Plugins
- Upgrade any installed Themes
Doing this every night will help keep your server secure from WordPress exploits which are regularly needing to be updated.
Just clone or unzip these scripts somewhere on your server and set up a cron job to call them each night.
WARNING: Do not run these scripts as root!
If you have a VPS server (or have root access), it's best to set up a crontab entry for the apache/httpd user.
So, assuming your apache/httpd user is "www-data" you would run as root:
crontab -e -u www-data
Otherwise, if you are on a shared hosting account, you can add the crontab for your own user:
crontab -e
Although it is more likely you will need to configure this via your web-based control panel (i.e. cPanel, etc.)
Example crontab entry:
0 0 * * * /path/to/wp-update-all.sh 2>&1 >/dev/null
Note: You don't have to throw away crontab logs, but once you know the script is working, all relevant logs are stored by the script so they are safe to discard.
Make sure that the directory you are writing your logs to and the directory where the scripts are in are writable by the user that runs the scripts.
This will need to be run as a user which has access to modify the files within each WordPress directory.
There are a few variables which you can configure at the top of the wp-update-all.sh
script:
WWW="/var/www"
You should point this to the directory which holds your WordPress installation directories. It will search recursively from this directory.
LOG_DIR="/tmp"
This is the directory where you want the script to write the success/error log files to.
TIMEZONE="America/Denver"
This is the time zone which you want the log files to display. See full list here.
The wp-update-all.sh
script will automatically update the WordPress CLI binary to latest version ensuring security flaws are fixed.