The ASA2 refresh cronjob is not working on cPanel

Problem

If you have configured the refresh cronjob as explained in the online documentation but you do not get any results, this might have something to do with the server-side PHP command used to execute the script. By default, ASA2 uses the “php” command to execute server-side scripts. On some servers this might be an older PHP version and will not work as expected. One solution is to use the “php5” command.

Solution

1. Create a new shell script in your user directory, e.g. /home/[your-username]/cronjobs/asa2_repo_refresh.sh

2. Insert the following lines in this file, where [path-to-your-website] must be replaced with the path to your WordPress installation starting with “/home”, like “/home/timo/asa2demo”:

Option 1

#!/bin/sh
php -f [path-to-your-website]/wp-content/plugins/amazon-simple-affiliate/lib/IfwAsa2/Wp/Plugin/Cli/Executables/script.php -- "[path-to-your-website]/wp-content/plugins/amazon-simple-affiliate" Asa2_Module_Repo_Cron_Refresh -lt=600 -limit=10 --verbose

Option 2

Another option is to add the path to the PHP 5 or 7 version to the environment variable “PATH” and then execute the shell script, like this:

#!/bin/sh 
export PATH=/opt/plesk/php/7.1/bin:$PATH && /bin/sh[path-to-your-website]/wp-content/plugins/amazon-simple-affiliate/scripts/script.sh Asa2_Module_Repo_Cron_Refresh --lifetime=3600 --verbose --limit=10 >/dev/null 2>&1

where “/opt/plesk/php/7.1/bin” must be adjusted to your server’s path to the newest PHP version.

3. Then configure this script in your cPanel cronjob panel as shown on the following screenshot:

cPanel cronjob configuration

 

Please also check the ASA2 cronjob calculator.

 

 

Short URL: https://bit.ly/asa2-custom-cron