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.
# 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/"
/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.
--path=/path/to/public_html.wp plugin status w3-total-cache
--url=https://example.com so WP‑CLI targets the right site.page after flush; for a single item the subcommand is post with --post_id or --permalink.# 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?
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
w3tc-cron.log) for Success.wp-cli.phar as shown above.--url= to target the correct site.