WPCursor is now WPOS see details

How to Script WordPress Maintenance Mode Across a Client Fleet Without Logging Into Each Site

WordPress maintenance mode is controlled by a single file in the WordPress root directory. Every site your agency manages can be flipped into maintenance mode from one terminal session, without logging into a single admin panel. This guide covers three scripting approaches that work across a fleet, the verification step most agencies skip, and the client communication runbook that should accompany every maintenance window you schedule.

Jun 14, 2026WPOSAI + WordPress How-Tos
In this article
  1. 01Why Site-by-Site Maintenance Mode Is an Operations Anti-Pattern
  2. 02How WordPress Maintenance Mode Works Under the Hood
  3. 03Three Ways to Script Maintenance Mode Across Multiple Sites
  4. 04How to Verify Maintenance Mode Is Active Before You Begin Work
  5. 05The Client Communication Runbook to Run Alongside Each Maintenance Window
  6. 06How to Record Maintenance Windows in Your Agency Decisions Log
Key takeaways
  • u003cpu003eLogging into 20 admin panels to toggle maintenance mode is not a scaling problem waiting for a bigger team; it is a systems design failure your agency can fix today.u003c/pu003eu003cpu003eT…
  • u003cpu003eWordPress maintenance mode is controlled entirely by a single file, u003cstrongu003e.maintenanceu003c/strongu003e, placed in the WordPress root directory.u003c/pu003eu003cpu003eWhen WordPre…
  • u003cpu003eEvery reliable fleet-wide maintenance approach reduces to one of three mechanisms: WP-CLI over SSH, direct file operations via SSH, or a WPOS site agent command.u003c/pu003eu003cpu003eu003c…
  • u003cpu003eBefore starting any migration, update, or infrastructure change, confirm that every site in the maintenance window is actually serving the maintenance screen to visitors.u003c/pu003eu003cpu…
  • u003cpu003eEvery maintenance window needs a paired client communication runbook that runs in parallel with the technical steps; the script and the client messages are two sides of the same operation.u…
  • u003cpu003eEvery maintenance window your agency runs is a decision, and decisions not recorded are institutional memory that disappears with the next team turnover.u003c/pu003eu003cpu003eThe most comm…

Why Site-by-Site Maintenance Mode Is an Operations Anti-Pattern

u003cpu003eLogging into 20 admin panels to toggle maintenance mode is not a scaling problem waiting for a bigger team; it is a systems design failure your agency can fix today.u003c/pu003eu003cpu003eThe average maintenance window for a WordPress agency managing 10 to 30 client sites looks like this: one person logs into each site, activates a maintenance screen, waits for the all-clear, then logs back in to deactivate. At 3 to 5 minutes per site, a 20-site fleet costs an hour of senior engineer time on access and navigation alone. That hour is not billable.u003c/pu003eu003cpu003eThe second cost is human error. When maintenance mode is triggered manually, sites get missed. A developer distracted by a message skips one. A client calls because their site is still live during a database migration. The operations failure is not the manual work itself; it is the absence of a repeatable, auditable runbook that executes identically every time.u003c/pu003eu003cpu003eThe fix is treating maintenance mode as a fleet-level command, not a per-site task. Every site in your fleet should respond to a single script: activate, verify, work, deactivate.u003c/pu003e

How WordPress Maintenance Mode Works Under the Hood

u003cpu003eWordPress maintenance mode is controlled entirely by a single file, u003cstrongu003e.maintenanceu003c/strongu003e, placed in the WordPress root directory.u003c/pu003eu003cpu003eWhen WordPress initializes in u003cemu003ewp-settings.phpu003c/emu003e, it checks whether a u003cemu003e.maintenanceu003c/emu003e file exists in the root of the installation. If the file is present and contains a PHP variable named u003cstrongu003e$upgradingu003c/strongu003e set to a Unix timestamp within the last 600 seconds, WordPress serves the maintenance screen instead of the normal site. The file itself contains a single line: u003cemu003eu0026lt;?php $upgrading = [timestamp]; ?u0026gt;u003c/emu003eu003c/pu003eu003cpu003eThe maintenance screen is customizable. If a file named u003cemu003emaintenance.phpu003c/emu003e exists inside your u003cemu003ewp-content/u003c/emu003e directory, WordPress serves it instead of the default u0022Briefly unavailable for scheduled maintenanceu0022 message. A well-run agency puts a branded maintenance page here with an estimated return time and an emergency contact for urgent issues.u003c/pu003eu003cpu003eTwo constraints your script must account for:u003c/pu003eu003culu003eu003cliu003eu003cstrongu003eThe 600-second window:u003c/strongu003e WordPress only respects the maintenance file if the timestamp inside it is within 10 minutes of the current time. For windows longer than 10 minutes, your script must refresh the file every 9 minutes by rewriting it with an updated timestamp, or use WP-CLI’s built-in maintenance mode command, which handles the refresh automatically.u003c/liu003eu003cliu003eu003cstrongu003eLogged-in admin bypass:u003c/strongu003e By default, WordPress allows logged-in administrators to view the site during maintenance. This is useful for post-activation verification, but it means client contacts with administrator accounts can still access the site during the window.u003c/liu003eu003c/ulu003eu003cpu003eMaintenance mode is, at its core, a file operation. Anything that can write and delete files on your server controls it.u003c/pu003e

Three Ways to Script Maintenance Mode Across Multiple Sites

u003cpu003eEvery reliable fleet-wide maintenance approach reduces to one of three mechanisms: WP-CLI over SSH, direct file operations via SSH, or a WPOS site agent command.u003c/pu003eu003cpu003eu003cstrongu003eMethod 1: WP-CLI over SSHu003c/strongu003eu003c/pu003eu003cpu003eWP-CLI’s u003cemu003emaintenance-modeu003c/emu003e subcommand is the most operator-friendly approach for agencies with server access. It handles the timestamp refresh internally, accepts a u003cemu003eu002du002dpathu003c/emu003e flag to target a specific WordPress installation, and returns a clean status on every call. To activate across a fleet, SSH into each host and run u003cemu003ewp maintenance-mode activate u002du002dpath=’/var/www/yoursite’ u002du002dallow-rootu003c/emu003e. To deactivate, replace u003cemu003eactivateu003c/emu003e with u003cemu003edeactivateu003c/emu003e. A bash loop over a list of your site hosts and paths completes a 20-site fleet in under 30 seconds and writes a log of every command executed.u003c/pu003eu003cpu003eu003cstrongu003eMethod 2: Direct file operations via SSHu003c/strongu003eu003c/pu003eu003cpu003eIf WP-CLI is not installed on the target servers, write the u003cemu003e.maintenanceu003c/emu003e file directly. SSH into each host and run: u003cemu003eecho ‘u0026lt;?php $upgrading = $(date +%s); ?u0026gt;’ u0026gt; /var/www/site/.maintenanceu003c/emu003e. For windows longer than 10 minutes, rerun this command every 9 minutes to refresh the timestamp. This method also lets you copy a custom u003cemu003emaintenance.phpu003c/emu003e to u003cemu003ewp-content/u003c/emu003e at activation time, so every site in the fleet displays a branded maintenance screen instead of the WordPress default. Deploy the template once, reference it from the activation script, and every client sees consistent branding during every window.u003c/pu003eu003cpu003eu003cstrongu003eMethod 3: WPOS site agentu003c/strongu003eu003c/pu003eu003cpu003eIf your agency runs a fleet through WPOS, maintenance mode is issued as a single command to the site agent. The agent handles the SSH connection, file write, and status verification per site, then logs the maintenance window to each site’s Playbook automatically. No shell loop required: the fleet responds as a unit and the operation is recorded without a separate documentation step.u003c/pu003e

How to Verify Maintenance Mode Is Active Before You Begin Work

u003cpu003eBefore starting any migration, update, or infrastructure change, confirm that every site in the maintenance window is actually serving the maintenance screen to visitors.u003c/pu003eu003cpu003eThe verification step is where most scripted approaches fail. A site may have returned an SSH error silently. A path variable may have been wrong. A server may have been unreachable at activation time. Beginning work without verifying puts live client traffic through a half-migrated state, and that is a client relationship event, not just a technical one.u003c/pu003eu003cpu003eThe fastest check: request each domain and read the HTTP status code. WordPress returns u003cstrongu003e503 Service Unavailableu003c/strongu003e when serving the maintenance screen. Any site returning u003cstrongu003e200 OKu003c/strongu003e is still fully live. Run a curl request against every domain after activation, and run the same check again after deactivation to confirm every site is back online.u003c/pu003eu003cpu003eDo not begin work until every site returns 503. A checklist that can be skipped is not a runbook; it is a suggestion.u003c/pu003eu003cpu003eFor agencies operating through WPOS, the Workspace shows each site’s current status. Maintenance mode appears as a status flag in the fleet view, so you can confirm the entire fleet from one screen without running a separate request per domain.u003c/pu003e

The Client Communication Runbook to Run Alongside Each Maintenance Window

u003cpu003eEvery maintenance window needs a paired client communication runbook that runs in parallel with the technical steps; the script and the client messages are two sides of the same operation.u003c/pu003eu003cpu003eClient-facing communication during a maintenance window is not a courtesy. It is the difference between a client who trusts your agency’s process and one who contacts your team at 2 AM because their site returned a 503 with no explanation.u003c/pu003eu003cpu003eu003cstrongu003eThe three-message sequence:u003c/strongu003eu003c/pu003eu003colu003eu003cliu003eu003cstrongu003e24 hours before the window:u003c/strongu003e u0022Hi [Client Name], we have a maintenance window scheduled for [Date] at [Time] [Timezone]. Your site will be offline for approximately [Duration]. We will send a confirmation when the work is complete.u0022u003c/liu003eu003cliu003eu003cstrongu003eAt window start:u003c/strongu003e u0022Maintenance has begun on [Site Name]. Expected completion: [Time]. We will notify you as soon as the site is back online.u0022u003c/liu003eu003cliu003eu003cstrongu003eAt window close:u003c/strongu003e u0022Maintenance on [Site Name] is complete. The site is live. Here is a summary of what changed: [Summary]. Please reach out if you notice anything unexpected.u0022u003c/liu003eu003c/olu003eu003cpu003eThe summary in the close message is not optional. Agencies that send u0022all doneu0022 with no detail are training clients to distrust their maintenance windows. Specifics, including version numbers or a one-line description of what was migrated or restructured, build the kind of retention that carries a $5,000-plus relationship through years of work.u003c/pu003eu003cpu003eWire the client messages to your maintenance script so they send automatically at the right moments. The activate step triggers the first notification. The deactivate step triggers the close. Removing human judgment from the timing removes the most common failure point in client communication during a maintenance window.u003c/pu003e

How to Record Maintenance Windows in Your Agency Decisions Log

u003cpu003eEvery maintenance window your agency runs is a decision, and decisions not recorded are institutional memory that disappears with the next team turnover.u003c/pu003eu003cpu003eThe most common knowledge gap for WordPress agencies is not technical skill. It is that the context behind past decisions dissolves when people leave. A client site migrated from shared hosting to a VPS in Q3. Why? Which server? Who approved it? What changed? If answering those questions requires hunting through chat history, your agency has a memory problem that compounds with every hire and every departure.u003c/pu003eu003cpu003eMaintenance windows are high-signal events. They almost always accompany a significant change: a core update, a hosting migration, a database restructure. Recording them creates a timeline that future team members can read in seconds rather than reconstruct over hours.u003c/pu003eu003cpu003eu003cstrongu003eWhat to record per maintenance window:u003c/strongu003eu003c/pu003eu003culu003eu003cliu003eDate, start time, and durationu003c/liu003eu003cliu003eSites included in the windowu003c/liu003eu003cliu003eReason for the windowu003c/liu003eu003cliu003eWhat changed, including specific version numbers, migrated paths, and configuration changesu003c/liu003eu003cliu003eWho ran the operationu003c/liu003eu003cliu003eWhether any anomalies occurred and how they were resolvedu003c/liu003eu003c/ulu003eu003cpu003eIf your agency operates on WPOS, each site carries a Decisions log in its Playbook. A maintenance window entry might read: u00222026-06-14: Maintenance window (22:00 to 23:15 UTC). Updated WordPress core from 6.7.1 to 6.8.0 across 18 client sites. No anomalies. Runbook version 3.1.u0022 Six months from now, that entry answers every question a new team member might ask about that site’s history.u003c/pu003eu003cpu003eFor a deeper look at building the monthly cadence that generates these records systematically, see u003ca href=u0022/blog/how-to-run-a-monthly-wordpress-maintenance-routine-across-many-client-sites/u0022u003ehow to run a monthly WordPress maintenance routine across many client sitesu003c/au003e. For the full framework that turns isolated windows into a scalable plan, see u003ca href=u0022/blog/how-to-build-a-wordpress-maintenance-plan-that-scales-across-many-client-sites/u0022u003ehow to build a WordPress maintenance plan that scales across many client sitesu003c/au003e.u003c/pu003e

Frequently Asked Questions

Yes. WordPress maintenance mode is controlled by a single file (.maintenance) in the WordPress root directory. You can activate and deactivate it using WP-CLI, a bash script over SSH, or by writing and deleting the file directly on the server. No third-party software is required.

WordPress only respects the .maintenance file if the timestamp inside it is within 600 seconds (10 minutes) of the current time. For longer maintenance windows, refresh the file every 9 minutes by rewriting it with an updated timestamp, or use WP-CLI’s maintenance-mode command, which handles this automatically.

Yes. By default, WordPress allows logged-in administrators to bypass the maintenance screen and view the site normally. This is useful for verification after activation, but it means any client contacts with administrator accounts can also access the site during the window.

Create a file named maintenance.php inside your wp-content/ directory. WordPress will serve this file instead of the default maintenance message whenever the .maintenance file is active. Your custom page can include your agency branding, an estimated return time, and an emergency contact number for urgent issues.

The most reliable approach for a fleet is WP-CLI over SSH, called in a loop across all sites. WP-CLI handles the timestamp refresh automatically, so the 10-minute expiry is not a concern for longer windows. For agencies running WPOS, maintenance mode is issued as a single site agent command that activates the entire fleet and logs each window to the site’s Playbook.

Your next WordPress site starts with a conversation.

1,000 free credits. Just describe what you need.

See It In Action