Wordpress - wp-cli Enabling Maintainance Mode

You can enable maintenance mode in WordPress by adding a .maintenance file to your root WordPress directory. It will need to include:

<?php
$upgrading = time();

With this file in place, your site will be in maintenance mode until you remove the file.


WP-CLI now has native commands for it.

# Activate Maintenance mode
$ wp maintenance-mode activate
# Deactivate Maintenance mode
$ wp maintenance-mode deactivate

See wp-cli/maintenance-mode-command for more information.


I use a plug-in for maintenance mode and always leave it "in" maintenance mode.

Practically you can then turn on/off the actual maintenance mode by turning on/off that plugi-in — which is easy through wp-cli:

# activate maintenance mode, flush caches and stuff
wp plugin activate ultimate-maintenance-mode
# do maintenance things
wp plugin deactivate ultimate-maintenance-mode
# flush caches again so the maintenance page does not show up

Tags:

Wp Cli