Automatic WordPress Updates with SVN

Want to keep your WordPress install up to date automatically? Follow these steps to add a cron job to update your WordPress install every 6 hours.

Set up the install

The WordPress install must be a Subversion checkout. You can grab the bleeding edge source with a command like this:

svn co http://core.svn.wordpress.org/trunk/ .

If you aren’t familiar with Subversion, start here:

Schedule the updates

Add the cron job from the command line.

  1. Edit the cron job list.
    crontab -e
  2. Add the cron job (edit the path to your WordPress install).
    MAILTO=""
    # Update WordPress install every six hours
    * */6 * * * svn up -q ~/path/to/your/wp-install
  3. Save and close.

To learn more about editing cron jobs from the command line search Google for man cron and man crontab.

You can also use a GUI tool like CronniX on Mac OS X to manage the cron jobs.

Notes

  • The -q parameter tells the svn update command to run silently so that you don’t have to worry about any output from the cron job. But, you should add the MAILTO definition if you want to completely silence output.
  • Some systems don’t recognize the */6 syntax for hourly notation. If you get an error when trying to save the cron job you might have to change it to comma-separated values instead: 0,6,12 or similar.

Published by

Lance Willett

My name is Lance, I am a blogger, product manager, software developer, and business executive creating high-quality, engaging, and customer-centered experiences for people online. México-born.

9 thoughts on “Automatic WordPress Updates with SVN”

  1. @Chris I’m sure you can do it with plugins, too. Change the svn update path to match the plugin’s path (as long as the plugin is a Subversion checkout, that is).

    @Dave You can do the database update manually when you visit your WP admin. To be clear, I’m not using this technique for production sites, just local development versions on my Mac.

    Like

  2. @Dave, to run the database update automatically after doing the upgrade, you merely need to invoke ../blog/admin/update.php and it will run the database update.

    @simpledream — while doing this on dev sites using the trunk may be great, especially if what you’re doing is developing wp code, plug-ins, themes, etc. However this shouldn’t be used for sites that will eventually get into production. The codex states that trunk is unstable and buggy, and that you should definitely not use it for production (I know you’re not doing that, I just want to warn any others that may come here.) Tracking the stable version is a bit harder since it relies on release tags rather than a pseudo head (like latest or stable or some such). Again, the codex gives a clue as to how to get a list of tags for releases, but it may still not be advisable to update a dev/test/staging area with the highest number on that list, given that the requirements may have changed. E.g. 3.2 requires php of at least 5.2 and mysql 5 which some people may not have upgraded to yet. This may not be a problem if you keep your dev box continuously upgraded with dependent software, but might be a problem for some people.

    Like

  3. Thanks for the quick tutorial Lance. I use this on my personal sites (live) and haven’t had any problems yet. It seems that WordPress trunk is still reasonably stable despite the warnings.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.