Fix “Not specified what to flush” in WP‑CLI (W3 Total Cache)

Running a CRON to clear a single page from W3 Total Cache and getting “Error: Not specified what to flush”? That message appears when the <cache> target is missing or incorrect in your WP‑CLI command. Below is the correct syntax to flush one page (by post ID or permalink), plus production‑safe CRON examples for hosts that use paths like /usr/local/bin/ea-php83.

I’m trying to flush one page from W3 Total Cache with WP‑CLI via CRON, but I get: “Error: Not specified what to flush”. What’s the correct command?

The error happens because WP‑CLI needs you to specify <cache> after flush. For a single page/post, use post plus either --post_id or --permalink.

Correct syntax (single page)

# From the WordPress root with the "wp" wrapper installed:
wp w3-total-cache flush post --post_id=816

# Or by URL:
wp w3-total-cache flush post --permalink="https://example.com/reviews/"

If you call wp-cli.phar directly (common on cPanel)

/usr/local/bin/ea-php83 /home/myaccount/wp-cli.phar \
  --path=/home/myaccount/public_html \
  w3-total-cache flush post --post_id=816

Expected output: Success: The page is flushed from cache successfully.

Quick checks if it still errors

  • Run in the WordPress root or pass --path=/path/to/public_html.
  • Make sure W3 Total Cache is active:
    wp plugin status w3-total-cache
  • Multisite? Add --url=https://example.com so WP‑CLI targets the right site.
  • Don’t use page after flush; for a single item the subcommand is post with --post_id or --permalink.

Useful alternates

# Flush all posts/pages cache:
wp w3-total-cache flush posts

# Flush everything (use sparingly in production):
wp w3-total-cache flush all

Why this works: The W3TC CLI expects a target after flush and supports flags like --post_id or --permalink for granular page clears.

How do I schedule this in crontab and make sure it actually runs?

CRON examples (system cron)

SSH into your server and edit the user’s crontab: crontab -e. These examples run every 30 minutes.

# Using wp-cli.phar and cPanel’s PHP 8.3 binary (adjust paths):
*/30 * * * * /usr/local/bin/ea-php83 /home/myaccount/wp-cli.phar \
  --path=/home/myaccount/public_html \
  w3-total-cache flush post --post_id=816 --quiet \
  >> /home/myaccount/w3tc-cron.log 2>&1
# If the `wp` wrapper is installed and in PATH:
*/30 * * * * cd /home/myaccount/public_html && \
  wp w3-total-cache flush post --permalink="https://example.com/reviews/" --quiet \
  >> /home/myaccount/w3tc-cron.log 2>&1

Verify it worked

  1. Check the log file you set (e.g., w3tc-cron.log) for Success.
  2. In WordPress, browse to your page and view source—you should see W3TC Page Cache debug comments if that setting is enabled.
  3. Optionally purge logs in W3TC to confirm a single‑page flush entry appears when your CRON fires.

Troubleshooting

  • WP‑CLI not found in CRON: Use full paths for PHP and wp-cli.phar as shown above.
  • Permissions: Run the cron as the same system user that owns the WordPress files (avoids file permission issues).
  • Multisite / domain mapping: Add --url= to target the correct site.
  • Plugin conflicts: If you still see loops or stale cache, temporarily disable other caching layers (server cache/CDN) to isolate W3TC.