updating wordpress on the command line and automating updates

If you have access to your host server it is much easier to update on the command line or use its crontab file to keep your site updated.

1. Set the web user - or whoever will need write access to the wordpress installation folder - to have /bin/bash as their shell. For example, like so:

sudo chsh www-data -s /bin/bash

The above assumes you're on ubuntu linux and the user is www-data.

2. Install the wp package.


wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

chmod u+x wp-cli.phar

mv wp-cli.phar /usr/local/bin/wp

wget https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash

cat wp-completion.bash >> ~/.bashrc

3. Run the update


sudo -u www-data -i -- wp core update --path=/var/www/website/


4. change the shell back

chsh www-data -s /usr/sbin/nologin


5. You can put all this into a script and then automate it under cron:

man crontab 5

Popular posts from this blog

bash + python script to find wordpress malware and delete it.

enabling web interface updates over FTP or directly

turning on debug mode