WordShell can handle the three basic operations of maintenance mode: to enter maintenance mode, to exit maintenance mode, and to check the state.
Note that these operations only operate upon WordPress’s core maintenance mode – the mode that is handled via a file named .maintenance in the WordPress root. There are other plugins which implement independent maintenance modes in non-standard ways, but WordShell does not interact with these.
Check maintenance mode state
To check whether a site is in maintenance mode, use –maintenancestate:
wordshell mysite --maintenancestate
mysite: Not in maintenance mode
As with many operations, you can perform this operation on every site using “all”:
wordshell all --maintenancestate
mysite: Not in maintenance mode
mysite2: Not in maintenance mode
anothersite: Not in maintenance mode
myhome: In maintenance mode
Note that when you install, update, rollback, restore or delete plugins, then WordShell automatically enters and leaves maintenance mode for you; you should not also do it manually. (In fact, if you do first enter maintenance mode manually, then WordShell will assume that the site is already being operated on, and it will wait until maintenance mode ends before it does anything).
Entering maintenance mode
To enter maintenance mode, use –entermaintenance:
wordshell mysite --entermaintenance
No output is shown for a successful operation (though for (S)FTP sites, you may see FTP messages flash across the screen for a short while). Also, if the site is already in maintenance mode, then no error will be shown.
By default, maintenance mode is entered indefinitely. You can also specify a number of minutes, after which maintenance mode will automatically terminate. e.g. To specify 10 minutes:
wordshell mysite --entermaintenance=10
If you do not specify a number of minutes, then you will need to leave maintenance mode explicitly.
Exiting maintenance mode
To exit maintenance mode, use –exitmaintenance:
wordshell mysite --exitmaintenance
No output is shown for a successful operation (though for (S)FTP sites, you may see FTP messages flash across the screen for a short while). Also, if the site was not in maintenance mode, then no error will be shown. Therefore you can use the following to ensure that all sites are out of maintenance mode:
wordshell all --exitmaintenance
You can also wait until maintenance mode is exited, without doing anything to manually clear it (e.g. if some other process has potentially put the site in maintenance mode). This command will not exit until maintenance mode is cleared:
wordshell all --waitmaintenance
More advanced usage and information
- Maintenance mode in WordPress is simply controlled by the existence of a file .maintenance in the WordPress root directory. Therefore, if you want to manually verify maintenance mode, or manually change it, you can simply manipulate that file. The command “wordshell mysite –login” is very helpful to quickly move you into a shell or FTP shell in the relevant directory.
- See http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/ for a blog with some helpful information on maintenance mode.