Product Update Cronjob



Use this cronjob to automatically update the items in your Products section (see Products).

This way you can avoid products being updated via API when a visitor opens a page.

ASA2 cronjob item refresh


To learn more about cronjobs in general, check out the Introduction chapter.


To learn more about setting up and using ASA2’s cronjobs, see the dedicated Cronjob Setup chapter.



The internal name of this cornjob is Asa2_Module_Repo_Cron_Refresh.

Therefore, use it with the Server-side execution like this:

bash Asa2_Module_Repo_Cron_Refresh --limit=10 --cat=31,40 --lifetime=7200

And with WP Cron API and ASA2’s Cron Wrapper like this:

$cronWrapper = new \Asa2\Cron\Wrapper('Asa2_Module_Repo_Cron_Refresh');
    'limit' => 10,
    'cat' => '31,40',
    'lifetime' => 7200

REST API Endpoint

The REST API endpoint name of this cronjob is product-update.


Check Cron REST API for more details about running ASA2’s cronjobs via URL.



It is highly recommended to use this cronjob in combination with option Server-side request limit handling.

If you are a power user with several hundret products to be refreshed via this cronjob, you should use the server-side cronjob.

Let’s assume you have 250 products in your Products section and you want to refresh them once a day. If you configure the cronjob to run once every hour, it should refresh 11 products in every run: 250 products / 24 hours = 10.41 products per hour.

To make sure all 250 products will be handled within 24 hours, set option lifetime to “86400” (seconds) which means a product will only get refreshed once per day.

Replace [wp_path] with the local server path of your WordPress installation.

This cron job will run at minute zero, every hour:

0 * * * * /[wp_path]/wp-content/plugins/amazon-simple-affiliate/scripts/ Asa2_Module_Repo_Cron_Refresh --lifetime=86400 --limit=11

There are several Options you can use to fit the cronjob to your requirements.

bash Asa2_Module_Repo_Cron_Refresh -lt=3600 --limit=50 -cat=31 tag=sale --verbose --log --logpath=/home/me/tmp/asa2

Cronjob Calculator

To find your perfect settings, please check ASA2’s cronjob calculator.



Use the cat option to filter the results by category ID. You can define multiple categories as comma separated list.

For example, only update repo items from category 31 and 40.

bash Asa2_Module_Repo_Cron_Refresh cat=31,40


Filters the result of prodcuts to be updated by country code. Mulitple country codes must be separated by comma.

// update 10 items from the US and German store:
bash Asa2_Module_Repo_Cron_Refresh --limit=10 --country_code=DE,US

// update all items from the Canadian store
bash Asa2_Module_Repo_Cron_Refresh --limit=-1 --country_code=CA


By using this option, only products that have an ASIN (i.e. Amazon products) will be updated.

bash Asa2_Module_Repo_Cron_Refresh --limit=10 --having_asin=1


Prints a help text showing all available options and how to use them.

bash Asa2_Module_Repo_Cron_Refresh --help


With this option you can limit the result to products of the specified IDs. Multiple IDs can be specified separated by commas (without spaces!).

bash Asa2_Module_Repo_Cron_Refresh id=254,636,4986


Use the lifetime option to only include items with a last refresh time older than the defined lifetime in seconds. Default is 86400 (one day).

For example, if you want to use the cronjob to only update products older than two hours, use a lifetime of 7200.

bash Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200


Limits the amount of products to be updated. Default is 20.


If this option is not used, the limit is automatically set to 20.

Example to raise the limit:

bash Asa2_Module_Repo_Cron_Refresh --limit=50

If you know what you are doing, you can turn off the limit with -1.


Working without a limit may not be beneficial if you have a lot of products in use, as the job could then load the system for a longer period of time.

Example to disable the limit:

bash Asa2_Module_Repo_Cron_Refresh --limit=-1


Activates the cronjob log. This will write the cronjob results to a file defined with logpath.


If you want to use the log feature, you must define a directory path. It must be writable. ASA2 will create a log file asa2reporefresh.log there. Using a log rotate function new files will be created when the old reaches 20MB.

bash Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200 --log --logpath=/home/me/tmp/asa2


Can be used to insert a fixed pause of the specified seconds between two API requests. This may help to avoid the RequestThrottled API issue.

// inserts a pause of 2 seconds between API requests
bash Asa2_Module_Repo_Cron_Refresh --limit=3 --pause=3 --verbose
ASA2 cronjob item refresh with pause option


With the php option, you can tell the ASA2 cronjob what PHP executable it should use to execute the command. With some webhosters the standard command “php” executes an outdated version and there is a special command for each version, e.g. “php74”, “php81” or “/opt/php81/bin/php”.

Please check which PHP version is required for the use of ASA2 here:

bash Asa2_Module_Repo_Cron_Refresh --limit=10 --php=php74
bash Asa2_Module_Repo_Cron_Refresh --limit=10 --php=/opt/php81/bin/php


With this option you can limit the result to products of shop specified by the IDs. Multiple IDs can be specified separated by commas (without spaces!).

bash Asa2_Module_Repo_Cron_Refresh shop_id=302,412


Use the tag option to filter the results by tag slug. You can define multiple tags as comma separated list.

For example, only update products with tag slug “green” and “sale”.

bash Asa2_Module_Repo_Cron_Refresh tag=green,sale

You can combine the cat and tag options. For example, only update repo items from category 31 and 40 with tag slug “green” and “sale”:

bash Asa2_Module_Repo_Cron_Refresh cat=31,40 tag=green,sale


Use the verbose option to get more information about the updated products.

bash Asa2_Module_Repo_Cron_Refresh --limit=50 --lifetime=7200 --verbose