Difference between revisions of "X-Cart:Cron.php - Script for Periodic Tasks"

From X-Cart 4 Classic
Jump to: navigation, search
(added It is recommended to leave this set to 0 and to run the script cron.php from the command line (for example, via crontab) no more than once per hour.)
m
Line 8: Line 8:
 
:* Sending out abandoned cart reminder notifications (when Abandoned Cart Reminder add-on module is used in automated mode).
 
:* Sending out abandoned cart reminder notifications (when Abandoned Cart Reminder add-on module is used in automated mode).
  
You can choose to launch the script <u>cron.php</u> from the command line or to set up X-Cart to launch this script automatically. Launching <u>cron.php</u> from the command line gives you a bit more control: you can decide exactly when you wish the script to be launched. Allowing X-Cart to launch this script automatically saves you time and effort: X-Cart will launch the script once per a predetermined number of user sessions.
+
To run the script <u>cron.php</u>, use one of the following methods:
 +
:* Use system cron to launch <u>cron.php</u> from the command line (via crontab).
 +
:* Configure X-Cart to launch <u>cron.php</u> automatically.  
  
If you choose to launch the script from the command line, you will need to adjust the setting '<u>Key for launch of the cron.php script</u>' field in the [[X-Cart:General_Options#Miscellaneous | '<u>General Settings/General options</u>']] section.
+
The first method - launching the script from the command line via crontab - enables you to exactly set the time when the script needs to be launched.  
  
If you decide to set up X-Cart to launch <u>cron.php</u> automatically, you will need to adjust the setting '<u>Run the script that launches execution of periodic tasks once per N user sessions</u>' in the [[X-Cart:General_Options#Miscellaneous | '<u>General Settings/General options</u>']] section.'' (It is recommended to leave this set to 0 and to run the script cron.php from the command line (for example, via crontab) no more than once per hour.)''
+
The second method relies on X-Cart's session mechanism: it enables you to specify the frequency of <u>cron.php</u> execution in connection with X-Cart user sessions (The script will be launched once per a predetermined number of user sessions. You set the number
 +
of sessions, "N", and the script <u>cron.php</u> is launched automatically every N-th user session).
  
<u>Example</u> of command line to launch the <u>cron.php</u> script:
+
If you decide to configure X-Cart to launch <u>cron.php</u> automatically in connection with user sessions, you will only need to adjust the setting '<u>Run the script that launches execution of periodic tasks once per N user sessions</u>' in the [[X-Cart:General_Options#Miscellaneous | '<u>General Settings/General options</u>']] section specifying the desired number of user sessions.
 +
 
 +
If you choose to launch the script from the command line, be sure to:
 +
:* Set a secret key for running <u>cron.php</u>. This can be done using the setting '<u>Key for launch of the cron.php script</u>' in the [[X-Cart:General_Options#Miscellaneous | '<u>General Settings/General options</u>']] section of X-Cart Admin.
 +
:* Keep the field '<u>Run the script that launches execution of periodic tasks once per N user sessions</u>' in the [[X-Cart:General_Options#Miscellaneous | '<u>General Settings/General options</u>']] section set to the default value of "0" (zero). This tells X-Cart that you do not wish it use the sessions mechanism to determine when to run <u>cron.php</u> and that you are going to use an external scheduler to launch this script.
 +
:* Run the script <u>cron.php</u> from the command line (for example, via crontab) no more than once every 30 minutes.
 +
 
 +
<u>Here's an example</u> of a command to launch <u>cron.php</u>:
  
 
<pre>
 
<pre>
Line 21: Line 31:
  
 
{{Note1|'''Note:''' You need to run cron.php using the so called "CLI" version of PHP. Ask your hosting administrator to tell you the location of PHP CLI on your server and configure cron to run the cron.php script using PHP CLI version.}}
 
{{Note1|'''Note:''' You need to run cron.php using the so called "CLI" version of PHP. Ask your hosting administrator to tell you the location of PHP CLI on your server and configure cron to run the cron.php script using PHP CLI version.}}
 +
 +
 +
'''Important:''' We strongly recommend launching <u>cron.php</u> from the command line over launching it by X-Cart based on the number of user sessions.
 +
  
 
==See also==
 
==See also==

Revision as of 16:00, 22 February 2018

X-Cart provides a script cron.php which you can use to launch execution of periodic tasks.

The tasks include:

  • Checking whether authorization has expired for any payment transactions in Pre-authorized status and setting the status of the respective orders to Declined.
  • Checking whether authorization is going to expire for any payment transactions in Pre-authorized status and sending email notifications thereof to the store's Orders department.
    Note: You can define how many days in advance such notifications must be sent using the setting 'Number of days in advance that you want a reminder to be sent to the Orders department email address about an order in Pre-authorized status for which the authorization period is going to expire' in the 'General settings/General options' section.
  • Sending out survey invitations (when X-Survey add-on module is used).
  • Sending out abandoned cart reminder notifications (when Abandoned Cart Reminder add-on module is used in automated mode).

To run the script cron.php, use one of the following methods:

  • Use system cron to launch cron.php from the command line (via crontab).
  • Configure X-Cart to launch cron.php automatically.

The first method - launching the script from the command line via crontab - enables you to exactly set the time when the script needs to be launched.

The second method relies on X-Cart's session mechanism: it enables you to specify the frequency of cron.php execution in connection with X-Cart user sessions (The script will be launched once per a predetermined number of user sessions. You set the number

of sessions, "N", and the script cron.php is launched automatically every N-th user session).

If you decide to configure X-Cart to launch cron.php automatically in connection with user sessions, you will only need to adjust the setting 'Run the script that launches execution of periodic tasks once per N user sessions' in the 'General Settings/General options' section specifying the desired number of user sessions.

If you choose to launch the script from the command line, be sure to:

  • Set a secret key for running cron.php. This can be done using the setting 'Key for launch of the cron.php script' in the 'General Settings/General options' section of X-Cart Admin.
  • Keep the field 'Run the script that launches execution of periodic tasks once per N user sessions' in the 'General Settings/General options' section set to the default value of "0" (zero). This tells X-Cart that you do not wish it use the sessions mechanism to determine when to run cron.php and that you are going to use an external scheduler to launch this script.
  • Run the script cron.php from the command line (for example, via crontab) no more than once every 30 minutes.

Here's an example of a command to launch cron.php:

cd /var/www/vhosts/yoursite.com/httpdocs/xcart; /usr/bin/php -d safe_mode=Off cron.php --key=c901d65fc15ff15d0ac0af967437d051
Note: You need to run cron.php using the so called "CLI" version of PHP. Ask your hosting administrator to tell you the location of PHP CLI on your server and configure cron to run the cron.php script using PHP CLI version.


Important: We strongly recommend launching cron.php from the command line over launching it by X-Cart based on the number of user sessions.


See also