Automating WordPress updates via wp-cli

I host a lot of WordPress sites which I’m in the process of moving from a stock Ubuntu server to Sympl. One thing I have on my old server is a Bash script which calls wp-cli to update WordPress core, plugins and themes (currently WordPress has built-in support for updating core, but you have to manually enable it for each and every theme/plugin, and it’s off by default).

Is this something which would be useful for other people to get into Sympl? For example, you might create a file config/wordpress, and if that existed the following commands would be run each night (with ${site_path} set to /srv/

/usr/bin/php /usr/local/bin/wordpress/wp-cli.phar core update --path=${site_path}
/usr/bin/php /usr/local/bin/wordpress/wp-cli.phar plugin update --all --path=${site_path}
/usr/bin/php /usr/local/bin/wordpress/wp-cli.phar theme update --all --path=${site_path}

I think it would need a package for wp-cli and then another package which depended on it to do the automatic cron job. I’m happy to look into it further if other people think it would be useful.

I’m not sure why it should become part of Sympl.

It’s just a cron job that’s unique to the sites you happen to be hosting?

Although I can see why this might be popular, I would regret any move towards making special features for Wordpress.
It deserves to be replaced, not supported, in my view.
Far better to support a good, secure and efficient CMS.

I’d be interested in the script, as I have quite a few WP sites whose owners are typically slack about updates, so I make myself an admin user and do them myself.
I agree that it doesn’t have to be part of Sympl, although I appreciate the security support for WP that is built into the standard Sympl apache2 config.

(edited to add: is the script basically the 3 lines quoted above? I don’t know anything about wp-cli)

It’s not unique to my sites, it should work with any WordPress installation.

There’s a bit more for error handling, but effectively it just calls wp-cli with the correct parameters (wp-cli is a command line tool that lets you automate WordPress tasks such as search and replace, installing/managing plugins etc.)

This sounds like a job for Sympl Scripts!

It should be fairly easy to find a WordPress install in a specified domain’s htdocs, and run wp-cli against it - if someone has any commonly useful scripts like the above (with adjustments so they install dependencies if needed for a basic Sympl install) I’d be willing to add them to the repo.

1 Like

It’s probably worth mentioning that blindly updating plugins and themes can avoid some issues, but also leaves content which didn’t come from the WordPress Repos without updates, so you may still run into security or comparability issues updating without checking.

There are third party services which collect WordPress security update information, which is one of the things that the Mythic ‘Managed Wordpress’ service covers, and means that only security updates get automatically applied, so this isn’t a one-stop hands off option for hassle free WordPress.

1 Like

If anyone else is interested, I’ve written a couple of scripts for this which are available on GitHub:

Basically there’s an ‘update everything’ script which searches for folders containing wp-config.php, and an ‘update one site’ script which calls wp-cli.

Needs a bit more robust error handling, but for now they work without any additional configuration.