Estimated Reading Time: 2 min
To clear the cache on Bluehost using a cron job command, follow these steps:
Step 1: Determine Your Cache Clearing Method
- WordPress Plugin Cache: If you’re using a caching plugin like WP Super Cache, W3 Total Cache, or another, identify the specific cache directory or plugin command for clearing cache.
- General Cache Clearing Script: If you’re managing a custom cache setup, create or use a PHP script to clear the cache.

Step 2: Example Commands for Common Scenarios (Bluehost)
1. Clear Cache Using WP-CLI
If you have WP-CLI installed on your Bluehost account:
/usr/local/bin/wp cache flush --path=/home/yourusername/public_html
- Replace
/home/yourusername/public_html
with the path to your WordPress installation.
2. Clear Cache with a Custom PHP Script
Create a PHP script to clear the cache and schedule it with cron.
PHP Script (clear-cache.php
):
<?php
define('WP_USE_THEMES', false);
require_once('/home/yourusername/public_html/wp-load.php');
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
echo "Cache cleared successfully.\n";
} else {
echo "Cache function not available.\n";
}
?>
Cron Job Command:
/usr/local/bin/php /home/yourusername/public_html/clear-cache.php
3. Clear Cache by Deleting Cache Files
Manually delete files from the cache directory (e.g., for WP Super Cache):
rm -rf /home/yourusername/public_html/wp-content/cache/*
4. Trigger Cache Clearing via HTTP Request
If a plugin or script provides an HTTP endpoint for clearing cache:
/usr/bin/curl -X GET "https://yourdomain.com/?clear_cache=true"
- Replace
https://yourdomain.com/?clear_cache=true
with your specific cache clearing URL.
Step 3: Set Up the Cron Job on Bluehost
- Log in to cPanel:
- Access your Bluehost account and open cPanel.
- Open the Cron Job Manager:
- In the Advanced section, click Cron Jobs.
- Define the Command:
- Paste the desired command into the Command field.
- Set the Schedule:
- Choose the frequency for running the cron job.
- Example:
0 */6 * * *
(Runs every 6 hours).
- Example:
- Choose the frequency for running the cron job.
- Save:
- Click Add New Cron Job.
Tips for Success
- Test Commands: Run the commands manually via SSH to ensure they work before scheduling a cron job.
- Use Logs for Debugging: Add logging to capture output:
/usr/local/bin/php /home/yourusername/public_html/clear-cache.php >> /home/yourusername/cron.log 2>&1
- Monitor Server Usage: Avoid scheduling cache clearing too frequently to prevent server strain.
By following these steps, you can automate clearing your Bluehost cache with cron jobs effectively!