mark.watero.us

Wordpress stuff, a statistics plugin, and jello

Built-in maintenance mode, or ‘Bringing down the house’

leave a comment

If you happen to run a large Wordpress powered site, you might be interested to know that there’s a little known gem of core functionality for placing your site into maintenance mode. This allows you to make upgrades, perform database operations, or do any number of potentially disruptive tasks without affecting any of your bloggers.

It’s simple too. Wordpress will first check to see if you have the file .maintenance (with a leading period, just like .htaccess) in the root path of your WP installation. If it finds this file, it then looks for the variable $upgrading and checks the time supplied by this variable against the current time. If the difference is less than ten minutes, Wordpress goes into maintenance mode.

Note: This time must be in Unix format. For example, if you wanted maintenance mode to run until Dec 24th, 2012, you would assign the unix timestamp of 1356336000 to $upgrading. See mktime() for one method of producing this timestamp.

You could easily create a bash script and cron job to do this automatically at specific intervals. Or, if you’re more hands on, you could add the following PHP;

<?php $upgrading = time(); ?>

…to your .maintenance file. This assigns the current time to $upgrading assuring your site will remain in maintenance mode until such time as you remove the file.

Now if you’ve just run out to test this, you probably noticed something right away. The default maintenance mode page is boring. Don’t worry though, the Wordpress development team is way ahead of us, and have provided an easy avenue to craft your own maintenance page.

After you’ve created your new maintenance mode masterpiece, simply place it in your wp-content/ directory, named maintenance.php and you’re all set. Enjoy!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • NewsVine
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter

Written by mark

September 11th, 2009 at 12:08 am

Posted in General

Tagged with ,

Leave a Reply