Finding and auto updating wordpress / themes / plugins with wp-cli

For many years I have maintained a shell script that checks and can update wordpress. Its great, it needs nearly nothing and is handy for basic diagnosis, however its not good as something that can update things on a cron so well which multiple people have asked about.

I have always suggested that if you run your own server, then a better option is wp-cli - its easy to install and could be run on a cron. This seems to be a little hard for some, unsure what to do and how to do it. So i wrote another script that finds all your wordpress installs, installs and makes sure wp-cli is going, and updates them on a cron.

This will work well at updating things, however it will also find your backups or other sites you may not want updated, and mess with them.
To avoid this place an empty file in these directories root named .noupdate

If i had a wordpress install in /home/liz/public_html/ and i have a backup in /home/liz/oldpublic_html i would run

touch /home/liz/oldpublic_html/.noupdate

So to Install and get this going here is the steps required ...

wget -O /usr/local/bin/
chmod +x /usr/local/bin/

Once installed. run it once to test


Once you have confirmed its working fine, then add a crontab that looks like this

echo "0 0 * * * root /usr/local/bin/ >/var/log/wp-update.log 2>&1" | sudo tee -a /etc/crontab > /dev/null

This will log to /var/log/wp-update.log , you may want to setup a logrotate for this log.

/var/log/wp-update.log {
    create 0664 root utmp
    rotate 5

Feel free to change the last part to mail you like this

0 0 * * * /usr/local/bin/ | mail -s "wp-cli update"

Another modification you can do is add in nice and ionice into the cron

echo "0 0 * * * root /usr/bin/ionice -c 3 /usr/bin/nice -n 19 /usr/local/bin/ >/var/log/wp-update.log 2>&1" | sudo tee -a /etc/crontab > /dev/null

By default this will search in /var/www and /home for wordpress installs, if you need it to check another location you can use the -p option

/usr/local/bin/ -p /srv/somepath 

Please email any bugs or issues to liz at