Get Started
How to refresh product feeds using cron jobs - AdTribes
  1. Home
  2. Knowledge Base
  3. General Feed Tips
  4. How to refresh product feeds using cron jobs

How to refresh product feeds using cron jobs

If your hosting environment throttles WordPress’s built-in task scheduler, or if you need feeds to refresh at a precise time that the plugin’s hourly, twice-daily, or daily intervals don’t match, you can drive feed refreshes from a server-level cron job instead. This gives you exact control over timing and avoids relying on visitor traffic to trigger WordPress’s scheduler.

Common symptoms: feeds stuck on old data, refresh times that drift between visits, or hosting environments that disable wp-cron.

Product Feed Pro and Product Feed Elite both support two approaches: a WP-CLI command (recommended) and a standalone PHP script for servers without WP-CLI.

If your feeds were not updating on scheduled runs on a case-sensitive server (Linux, Kinsta, or similar), this was a known bug fixed in version 13.5.4. Updating the plugin resolves the issue without requiring a custom cron setup.

Before you start

  • Product Feed Pro or Product Feed Elite installed and active
  • At least one product feed created and configured
  • SSH or cPanel access to your server to add cron jobs
  • Your feed ID (see Step 1 in either method below)
  • Version 13.5.4 or later for WP-CLI support

WP-CLI is available on most managed WordPress hosts. It’s the simplest and most reliable way to trigger a feed refresh from a server cron job. No PHP file to manage, no WordPress bootstrapping required.

Step 1: Find your feed ID

  1. Go to Product Feed → Manage Feeds in your WordPress admin.
  2. Click the feed you want to refresh.
  3. Look at the browser URL bar. The feed ID is the value of the id parameter — for example, admin.php?page=adt-edit-feed&id=123 means your feed ID is 123.
Browser address bar showing a WordPress admin URL with page=adt-edit-feed&id=13 highlighted.

Step 2: Disable the built-in refresh interval

To prevent the plugin’s scheduler from running a duplicate refresh alongside your cron job:

  1. While editing the feed, go to the General tab.
  2. Set Refresh interval to No Refresh.
  3. Click Save Changes.
Feed with "No Refresh" Refresh Interval

Step 3: Add the server cron job

On your server, add a cron entry that runs wp adt-feed refresh at your chosen schedule. Replace /path-to-wordpress with your site’s actual root directory and 123 with your feed ID:

0 2 * * * cd /path-to-wordpress && wp adt-feed refresh 123 >> /tmp/feed-refresh-123.log 2>&1

This example runs at 2:00 AM every day. Adjust the schedule expression to match your needs.

If wp is not in your server’s default PATH, use the full path to the WP-CLI binary (e.g. /usr/local/bin/wp) instead of just wp.

To refresh multiple feeds in a single cron job, list their IDs separated by spaces:

0 2 * * * cd /path-to-wordpress && wp adt-feed refresh 123 456 789

Method 2: PHP script

Use this method if your server doesn’t support WP-CLI.

The PHP script initiates feed generation by queuing it through Action Scheduler. The actual processing happens in the background — the feed won’t update in the same instant the script runs. Make sure WordPress cron (or a separate server cron hitting wp-cron.php) is active so Action Scheduler can complete the batches.

Step 1: Find your feed ID

Follow the same steps as in Method 1, Step 1 above. Click your feed to edit it and read the id= value from the URL.

Step 2: Create the PHP script

Create a new file called feed-refresh-123.php (replace 123 with your feed ID) and save it in your child theme directory — for example, wp-content/themes/your-child-theme/feed-refresh-123.php.

Add this code to the file, replacing 123 with your actual feed ID:

/**
 * Product Feed Generation Cron Script
 */

// Start timing
$start_time = microtime(true);

// Simple logging function
function log_message($message) {
    $timestamp = date('Y-m-d H:i:s');
    $log_entry = "[$timestamp] $message";
    
    error_log($log_entry);
    echo $log_entry . "\n";
}

log_message("Feed generation started");

try {
    // Load WordPress (3 levels up from wp-content/themes/your-child-theme/)
    require_once(__DIR__ . '/../../../wp-load.php');
    
    $feed_id = 123; // Change this to your actual feed ID
    
    $feed = \AdTribes\PFP\Helpers\Product_Feed_Helper::get_product_feed($feed_id);
    
    if ($feed) {
        $feed->generate();
        
        $execution_time = round(microtime(true) - $start_time, 2);
        log_message("Feed ID $feed_id generated successfully in {$execution_time}s");
        
    } else {
        log_message("ERROR: Failed to get feed ID $feed_id");
    }
    
} catch (Exception $e) {
    log_message("ERROR: " . $e->getMessage());
}

Step 3: Disable the built-in refresh interval

Follow the same steps as in Method 1, Step 2 above — set Refresh interval to No Refresh in the General tab.

Step 4: Add the server cron job

Add the following cron entry on your server, replacing the paths with your actual values:

0 2 * * * php /path-to-wordpress/wp-content/themes/your-child-theme/feed-refresh-123.php >> /path-to-wordpress/wp-content/themes/your-child-theme/feed-refresh-123.log 2>&1

This runs at 2:00 AM every day. The output is written to a log file in the same directory, so you can check if the script ran and whether it produced any errors.

To run multiple feeds independently, create a separate PHP file and cron entry for each feed.

Troubleshooting

The feed is not updating after the cron runs
First, check the log file the cron job writes to. If the log is empty, the cron entry is not running. Double-check the file path and that the cron daemon is active on your server.

If the log shows output but the feed still doesn’t update, verify the feed ID is correct: open the feed in WordPress admin and confirm the id= value in the URL matches the ID in your script or WP-CLI command.
Scheduled feeds are not updating on a Linux or Kinsta server
This was a known bug (fixed in version 13.5.4) where the plugin wrote the refreshed feed to a lowercase filename, while the feed URL used the original mixed-case filename. On case-sensitive filesystems, these are two different files. Update the plugin to version 13.5.4 or later to resolve it.
WP-CLI command returns “command not found”
The wp binary may not be in your server’s PATH. Contact your host to confirm WP-CLI is available and ask for the full path. Then update your cron entry to use the full path (e.g. /usr/local/bin/wp adt-feed refresh 123).
The PHP script returns a fatal error about a missing class
The AdTribes\PFP\Helpers\Product_Feed_Helper class is only available after the plugin has loaded via wp-load.php. Make sure the require_once line points to the correct wp-load.php path. The path must match your WordPress installation root — not a subdirectory.

FAQ

Do I need Product Feed Elite for this?
No. Both methods work with Product Feed Pro (free) and Product Feed Elite.
Can I keep the built-in refresh interval enabled alongside a server cron?
You can, but it’s not recommended. Running both at the same time may cause the feed to generate twice in close succession. Disable the built-in interval and let the server cron control the schedule.
How do I find the right cron schedule expression?
Use a cron expression generator (search “cron expression generator”) to build the schedule you need. The five fields are: minute, hour, day of month, month, day of week.
Does the PHP script approach work on shared hosting?
Yes, as long as you have cPanel or SSH access to add cron jobs and the server can run PHP from the command line. If your host doesn’t support command-line PHP or cron jobs, use the plugin’s built-in Refresh interval setting instead.

Need more help?

If you’re on Product Feed Elite, open a support ticket, and our team will help you configure the cron setup for your environment.

If you’re on Product Feed Pro, post your question in the WordPress.org support forum.

Was this article helpful?

Related Articles

Complete Your Purchase
AdTribes WooCommerce Product Feed

The best WooCommerce product feed plugin

  • AdTribes Pty Ltd
    ABN: 40 675 636 816
Product
Resources & Info
Partner Sites
Rymera