Difference between revisions of "Cron Job Issues"
(→Oops! Something went wrong and we couldn't process your request) |
m (→Segmentation fault) |
||
(47 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{troubleshooting}} | {{troubleshooting}} | ||
− | + | You may encounter some common problems and errors that can occur when running the WHMCS cron job. | |
+ | |||
+ | For more information about troubleshooting cron job issues, see [https://help.whmcs.com/m/automation/c/195647 our cron and automation troubleshooting guides]. | ||
==Troubleshooting== | ==Troubleshooting== | ||
− | There are several techniques available for troubleshooting problems | + | |
+ | There are several techniques available for troubleshooting the problems that you may encounter with the cron job: | ||
+ | |||
+ | ===Cron Execution=== | ||
+ | |||
+ | If you do not receive the daily cron digest email, see a warning on the System Health Status overview page, or on the Automation Status page then this indicates the cron not running. Troubleshooting and resolving this is a matter of priority, as the daily automation tasks are an integral part of WHMCS. | ||
+ | |||
+ | Detailed steps on how to debug the cron execution can be found in our [https://help.whmcs.com/m/automation/l/683269-advanced-cron-troubleshooting|Advanced Cron Troubleshooting] Guide. | ||
===Run the cron job in your browser=== | ===Run the cron job in your browser=== | ||
− | + | ||
− | + | To do this: | |
− | + | ||
+ | # In the WHMCS admin area, go to the '''[[Other Tab|Other]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''. | ||
+ | # Enable the '''Display Errors''' option. | ||
+ | # Visit the <tt>cron.php</tt> file in your browser. For example: <source lang="php">http://www.example.com/whmcs/crons/cron.php</source> | ||
+ | |||
+ | <div class="docs-alert-info"> | ||
+ | <span class="title">Note</span><br /> | ||
+ | Executing <tt>cron.php</tt> from a web browser is not possible if the <tt>/crons</tt> directory is not inside a web-accessible directory. It will be subject to limitations that apply to executing any PHP script via a web browser such as, timeouts and won't provide any output on screen to examine (the execution must be observed from the Activity Log). Where possible, executing <tt>cron.php</tt> from your server's command line interface is the recommended troubleshooting method. | ||
+ | </div> | ||
===Run the cron job from the server command line=== | ===Run the cron job from the server command line=== | ||
− | |||
− | |||
− | |||
− | |||
− | + | To do this: | |
− | + | ||
− | + | # Access your server's command line. | |
− | + | # Copy the cron job command for the <tt>cron.php</tt> file from your server's cron tab. <source lang="php">crontab -u userName -l</source> Where <tt>userName</tt> represents the user on the server for which the cron command is configured under. | |
− | + | # Execute the command you copied with the addition of the verbose option:<source lang="php">php -q /path/to/whmcs/crons/cron.php -vvv</source> | |
− | + | # Examine the output for any errors. | |
+ | # To execute all daily automation tasks, adjust the cron command again to add in the force option:<source lang="php">php -q /path/to/whmcs/crons/cron.php --force -vvv</source> This should only ever be executed once in any 24 hour period. Do this with the explicit intention of identifying why the cron may not be completing successfully. | ||
+ | |||
+ | For more information, see [[Crons#Commands|Cron Commands.]] | ||
+ | |||
+ | ===Run the cron job from the server command line with debugging enabled=== | ||
+ | |||
+ | To do this: | ||
+ | * Make sure you have enabled '''Display Errors''' in the '''[[Other Tab|Other]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''. | ||
+ | * Access your server's command line. | ||
+ | * Make sure you have enabled '''display_errors''' in your command line PHP environment: <source lang="php">php -i | grep display_errors | ||
+ | display_errors => STDOUT => STDOUT</source> | ||
+ | * Copy the cron job command for the <tt>cron.php</tt> file from your server's crontab: <source lang="php">crontab -u userName -l</source> | ||
+ | * Add the --force option to the end of the cron command and execute it:<source lang="php">php -q /path/to/whmcs/crons/cron.php all --force -vvv</source> | ||
+ | *Examine the output for any errors. The final line output should be "'''[OK] Completed'''". | ||
==Common Errors== | ==Common Errors== | ||
===Site error: the file /path/to/crons/cron.php requires the ionCube PHP Loader ioncube_loader_lin_5.6.so to be installed by the website operator=== | ===Site error: the file /path/to/crons/cron.php requires the ionCube PHP Loader ioncube_loader_lin_5.6.so to be installed by the website operator=== | ||
− | |||
− | + | Seeing this error output indicates that the PHP configuration for your WHMCS installation may be different than the one on the command line. | |
+ | |||
+ | Log in as the same user that the cron job runs under. Then, run the following command at the server's command line to see the version information for your PHP and ionCube Loader® configurations: | ||
<source lang="php"> | <source lang="php"> | ||
php -v | php -v | ||
</source> | </source> | ||
+ | |||
You should get an output along the lines of: | You should get an output along the lines of: | ||
Line 44: | Line 73: | ||
</source> | </source> | ||
− | If the | + | If the <tt>with the ionCube PHP Loader</tt> line is absent, this indicates that ionCube Loader is not available for this user. Work with your hosting provider or server administrator to ensure that ionCube Loader is available to the cron job user. |
===Unable to communicate with the WHMCS installation=== | ===Unable to communicate with the WHMCS installation=== | ||
− | |||
− | * Open the /crons/config.php file | + | This error occurs when the <tt>cron.php</tt> file is unable to communicate with the WHMCS installation. This typically occurs when you are using a custom location for the <tt>/crons</tt> directory. The <tt>cron.php</tt> file will look for the WHMCS directory in the location that you specified in the <tt>/crons/config.php</tt> file. To resolve this error: |
− | * Ensure the $whmcspath line is uncommented by removing the preceding // characters. | + | |
− | * Ensure the | + | * Open the <tt>/crons/config.php</tt> file. |
− | + | * Ensure the <tt>$whmcspath</tt> line is uncommented by removing the preceding <tt>//</tt> characters. | |
+ | * Ensure the <tt>$whmcspath</tt> path is the full system path to your WHMCS directory. This is the directory that contains the <tt>init.php</tt> and <tt>clientarea.php</tt> files. | ||
+ | |||
+ | When you finish, the entire file will look like this: | ||
<source lang="php"> | <source lang="php"> | ||
Line 79: | Line 110: | ||
===Could not open input file: /path/to/crons/cron.php === | ===Could not open input file: /path/to/crons/cron.php === | ||
− | This error occurs when the cron.php file is not present in directory path | + | |
+ | This error occurs when the <tt>cron.php</tt> file is not present in specified directory path. Check the path and correct it, or ensure the <tt>cron.php</tt> file is present. | ||
+ | |||
+ | ===Oops! Something went wrong and we couldn't process your request=== | ||
+ | |||
+ | This indicates that a fatal PHP error has occurred. Go to the '''[[Other Tab|Other]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''. Select 'Display Errors'. Then, run the cron job again. The system will display the full error. The error normally indicates an issue with one or more modules. | ||
+ | |||
+ | For example, you could see: | ||
+ | |||
+ | <source lang="php"> | ||
+ | <p class="debug">exception 'Whoops\Exception\ErrorException' with message 'Cannot redeclare class module_class' in /home/whmcs/public_html/modules/gateways/module-name/module-file.php:16<br /> | ||
+ | </source> | ||
+ | |||
+ | If the error references a third party module you are using, you will need to contact the developers of the module to review and resolve the error. If the error references a WHMCS-developed and shipped module, contact our Support Team. It may also indicate an issue with the PHP configuration. For more information, see the sections below. | ||
===Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20480 bytes)=== | ===Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20480 bytes)=== | ||
− | This indicates that cron has | + | |
− | You can check the limit | + | This error indicates that the system is terminating the cron job because it has exceeded the 'memory_limit' value of 32 MB. Increase this to 64 MB (128 MB if possible) to resolve this. Contact your server administrator or hosting provider for assistance with this. |
+ | |||
+ | You can check the limit using this command: | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
php -ini | grep "memory_limit" | php -ini | grep "memory_limit" | ||
+ | </source> | ||
+ | |||
+ | You can also set the memory limit (<tt>memory_limit</tt>) directly in the cron command. For example: | ||
+ | <source lang="php"> | ||
+ | php -d memory_limit=128M -q /path/to/whmcs/crons/cron.php | ||
</source> | </source> | ||
===The file /path/to/crons/cron.php is corrupted=== | ===The file /path/to/crons/cron.php is corrupted=== | ||
− | + | ||
+ | You may see this error in version 7.5 and above. This error will occur if you are running ionCube Loader 10.0 or earlier. WHMCS 7.5 requires ionCube Loader 10.1.0 or above. If your WHMCS installation is working, it indicates that the PHP configuration for your WHMCS installation may be different than the one that you use on the command line. To check this, you can again use the command below: | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
php -v | php -v | ||
</source> | </source> | ||
− | Look for the following line to identify the ionCube | + | |
+ | Look for the following line to identify the ionCube Loader version: | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.0, Copyright | with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.0, Copyright | ||
(c) 2002-2018, by ionCube Ltd. | (c) 2002-2018, by ionCube Ltd. | ||
</source> | </source> | ||
+ | |||
===Error: Call to undefined function curl_init()=== | ===Error: Call to undefined function curl_init()=== | ||
− | This error indicates | + | |
+ | This error indicates that the system is terminating the cron job because the 'curl' extension is missing. To check this, run the following command: | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
php -m | php -m | ||
</source> | </source> | ||
− | |||
− | === | + | A similar error may also occur if the 'curl_init' function is a disabled function in your PHP configuration. |
− | This indicates | + | |
+ | ===Whoops\Exception\ErrorException' with message 'Maximum execution time of 30 seconds exceeded=== | ||
+ | |||
+ | This error indicates that the system is terminating the cron job because it has exceeded the 'max_execution_limit' value of 30 seconds. Increase this to an appropriate value for the size of your installation. For most servers, a limit of '120' is sufficient, but larger servers may need a value of '300'. | ||
+ | |||
+ | You can check the limit using this command: | ||
+ | <source lang="php">php -ini | grep "max_execution_time"</source> | ||
+ | |||
+ | You can also set the <tt>max_execution_time</tt> value directly in the cron command. For example: | ||
+ | <source lang="php"> | ||
+ | php -d max_execution_time=300 -q /path/to/whmcs/crons/cron.php | ||
+ | </source> | ||
+ | |||
+ | ===The cron is using a different timezone=== | ||
+ | |||
+ | If your cron job is using a different timezone than your website's, you can change the timezone (<tt>date.timezone</tt>) directly in the cron command: | ||
<source lang="php"> | <source lang="php"> | ||
− | + | php -d date.timezone="Europe/London" -q /path/to/whmcs/crons/cron.php | |
</source> | </source> | ||
− | |||
− | === | + | ===Segmentation Fault=== |
− | This error indicates | + | |
+ | This error does not directly relate to the WHMCS software and can occur for many different reasons. It most commonly indicates that PHP is crashing and suggests there is an issue with your PHP installation (for example, a malfunctioning extension). It is something your server administrator or hosting provider would need to investigate, possibly using the <tt>strace</tt> utility. | ||
+ | |||
+ | In some instances, the OpCache PHP extension causes this error. To determine if it is the cause, temporarily disable it by changing the cron job to the following command: | ||
+ | |||
+ | <source lang="php">php -q -d opcache.enable_cli=0 /path/to/whmcs/crons/cron.php</source> | ||
+ | |||
+ | If the error no longer occurs after making that change, we recommend reverting it and disabling the OpCache PHP extension on the server to resolve this. | ||
+ | |||
+ | ===Domain renew link in emails is broken=== | ||
+ | |||
+ | Under some PHP server configurations, the system generates the URL for the domain renewal link in domain renewal reminder emails incorrectly. | ||
+ | |||
+ | You can usually fix this by using the correct PHP binary on your cron job. Alternatively, you can adjust the cron job to work around the issue by formatting your cron command, as in the following example: | ||
+ | |||
<source lang="php"> | <source lang="php"> | ||
− | php - | + | cd /path/to/crons/ && php -q cron.php |
</source> | </source> | ||
− | === | + | ===Could not connect to database=== |
− | This error is | + | |
+ | This error occurs when the <tt>cron.php</tt> script cannot access your MySQL® database. This is often because the PHP configuration that the <tt>cron.php</tt> script runs under is missing one or all of the following extensions: | ||
+ | |||
+ | * PDO | ||
+ | * PDO MySQL | ||
+ | * MySQLi | ||
+ | |||
+ | It can also be the result of a jailed environment with strict limitations. Your system administrator or hosting provider can check for the required extensions and any environmental limitations by testing a connection to the database and resolving any issues. | ||
+ | |||
{{troubleshooting}} | {{troubleshooting}} |
Latest revision as of 20:11, 16 April 2024
You may encounter some common problems and errors that can occur when running the WHMCS cron job.
For more information about troubleshooting cron job issues, see our cron and automation troubleshooting guides.
Contents
- 1 Troubleshooting
- 2 Common Errors
- 2.1 Site error: the file /path/to/crons/cron.php requires the ionCube PHP Loader ioncube_loader_lin_5.6.so to be installed by the website operator
- 2.2 Unable to communicate with the WHMCS installation
- 2.3 Could not open input file: /path/to/crons/cron.php
- 2.4 Oops! Something went wrong and we couldn't process your request
- 2.5 Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20480 bytes)
- 2.6 The file /path/to/crons/cron.php is corrupted
- 2.7 Error: Call to undefined function curl_init()
- 2.8 Whoops\Exception\ErrorException' with message 'Maximum execution time of 30 seconds exceeded
- 2.9 The cron is using a different timezone
- 2.10 Segmentation Fault
- 2.11 Domain renew link in emails is broken
- 2.12 Could not connect to database
Troubleshooting
There are several techniques available for troubleshooting the problems that you may encounter with the cron job:
Cron Execution
If you do not receive the daily cron digest email, see a warning on the System Health Status overview page, or on the Automation Status page then this indicates the cron not running. Troubleshooting and resolving this is a matter of priority, as the daily automation tasks are an integral part of WHMCS.
Detailed steps on how to debug the cron execution can be found in our Cron Troubleshooting Guide.
Run the cron job in your browser
To do this:
- In the WHMCS admin area, go to the Other tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
- Enable the Display Errors option.
- Visit the cron.php file in your browser. For example:
http://www.example.com/whmcs/crons/cron.php
Note
Executing cron.php from a web browser is not possible if the /crons directory is not inside a web-accessible directory. It will be subject to limitations that apply to executing any PHP script via a web browser such as, timeouts and won't provide any output on screen to examine (the execution must be observed from the Activity Log). Where possible, executing cron.php from your server's command line interface is the recommended troubleshooting method.
Run the cron job from the server command line
To do this:
- Access your server's command line.
- Copy the cron job command for the cron.php file from your server's cron tab. Where userName represents the user on the server for which the cron command is configured under.
crontab -u userName -l
- Execute the command you copied with the addition of the verbose option:
php -q /path/to/whmcs/crons/cron.php -vvv
- Examine the output for any errors.
- To execute all daily automation tasks, adjust the cron command again to add in the force option:This should only ever be executed once in any 24 hour period. Do this with the explicit intention of identifying why the cron may not be completing successfully.
php -q /path/to/whmcs/crons/cron.php --force -vvv
For more information, see Cron Commands.
Run the cron job from the server command line with debugging enabled
To do this:
- Make sure you have enabled Display Errors in the Other tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
- Access your server's command line.
- Make sure you have enabled display_errors in your command line PHP environment:
php -i | grep display_errors display_errors => STDOUT => STDOUT
- Copy the cron job command for the cron.php file from your server's crontab:
crontab -u userName -l
- Add the --force option to the end of the cron command and execute it:
php -q /path/to/whmcs/crons/cron.php all --force -vvv
- Examine the output for any errors. The final line output should be "[OK] Completed".
Common Errors
Site error: the file /path/to/crons/cron.php requires the ionCube PHP Loader ioncube_loader_lin_5.6.so to be installed by the website operator
Seeing this error output indicates that the PHP configuration for your WHMCS installation may be different than the one on the command line.
Log in as the same user that the cron job runs under. Then, run the following command at the server's command line to see the version information for your PHP and ionCube Loader® configurations:
php -v
You should get an output along the lines of:
PHP 5.4.43 (cli) (built: Aug 2 2015 02:44:35)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with the ionCube PHP Loader v4.7.5, Copyright (c) 2002-2014, by ionCube Ltd.
If the with the ionCube PHP Loader line is absent, this indicates that ionCube Loader is not available for this user. Work with your hosting provider or server administrator to ensure that ionCube Loader is available to the cron job user.
Unable to communicate with the WHMCS installation
This error occurs when the cron.php file is unable to communicate with the WHMCS installation. This typically occurs when you are using a custom location for the /crons directory. The cron.php file will look for the WHMCS directory in the location that you specified in the /crons/config.php file. To resolve this error:
- Open the /crons/config.php file.
- Ensure the $whmcspath line is uncommented by removing the preceding // characters.
- Ensure the $whmcspath path is the full system path to your WHMCS directory. This is the directory that contains the init.php and clientarea.php files.
When you finish, the entire file will look like this:
<?php
/**
* Custom Crons Directory Configuration
*
* This crons folder may be moved to any place above or below the docroot.
*
* We recommend locating it outside the docroot to prevent browser based access.
*
* Upon moving it, you must provide the path to your WHMCS installation to
* allow the cron task files to communicate with the parent WHMCS installation.
*
* To do this, rename this file config.php, then uncomment and enter the full
* path to the WHMCS root directory in the $whmcspath variable below.
*
* You must also provide the appropriate path to the crons folder in the
* $crons_dir variable inside the WHMCS master configuration file.
*
* For more information please see http://docs.whmcs.com/Custom_Crons_Directory
*/
$whmcspath = '/home/username/public_html/whmcs/';
Could not open input file: /path/to/crons/cron.php
This error occurs when the cron.php file is not present in specified directory path. Check the path and correct it, or ensure the cron.php file is present.
Oops! Something went wrong and we couldn't process your request
This indicates that a fatal PHP error has occurred. Go to the Other tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings. Select 'Display Errors'. Then, run the cron job again. The system will display the full error. The error normally indicates an issue with one or more modules.
For example, you could see:
<p class="debug">exception 'Whoops\Exception\ErrorException' with message 'Cannot redeclare class module_class' in /home/whmcs/public_html/modules/gateways/module-name/module-file.php:16<br />
If the error references a third party module you are using, you will need to contact the developers of the module to review and resolve the error. If the error references a WHMCS-developed and shipped module, contact our Support Team. It may also indicate an issue with the PHP configuration. For more information, see the sections below.
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 20480 bytes)
This error indicates that the system is terminating the cron job because it has exceeded the 'memory_limit' value of 32 MB. Increase this to 64 MB (128 MB if possible) to resolve this. Contact your server administrator or hosting provider for assistance with this.
You can check the limit using this command:
php -ini | grep "memory_limit"
You can also set the memory limit (memory_limit) directly in the cron command. For example:
php -d memory_limit=128M -q /path/to/whmcs/crons/cron.php
The file /path/to/crons/cron.php is corrupted
You may see this error in version 7.5 and above. This error will occur if you are running ionCube Loader 10.0 or earlier. WHMCS 7.5 requires ionCube Loader 10.1.0 or above. If your WHMCS installation is working, it indicates that the PHP configuration for your WHMCS installation may be different than the one that you use on the command line. To check this, you can again use the command below:
php -v
Look for the following line to identify the ionCube Loader version:
with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v10.2.0, Copyright
(c) 2002-2018, by ionCube Ltd.
Error: Call to undefined function curl_init()
This error indicates that the system is terminating the cron job because the 'curl' extension is missing. To check this, run the following command:
php -m
A similar error may also occur if the 'curl_init' function is a disabled function in your PHP configuration.
Whoops\Exception\ErrorException' with message 'Maximum execution time of 30 seconds exceeded
This error indicates that the system is terminating the cron job because it has exceeded the 'max_execution_limit' value of 30 seconds. Increase this to an appropriate value for the size of your installation. For most servers, a limit of '120' is sufficient, but larger servers may need a value of '300'.
You can check the limit using this command:
php -ini | grep "max_execution_time"
You can also set the max_execution_time value directly in the cron command. For example:
php -d max_execution_time=300 -q /path/to/whmcs/crons/cron.php
The cron is using a different timezone
If your cron job is using a different timezone than your website's, you can change the timezone (date.timezone) directly in the cron command:
php -d date.timezone="Europe/London" -q /path/to/whmcs/crons/cron.php
Segmentation Fault
This error does not directly relate to the WHMCS software and can occur for many different reasons. It most commonly indicates that PHP is crashing and suggests there is an issue with your PHP installation (for example, a malfunctioning extension). It is something your server administrator or hosting provider would need to investigate, possibly using the strace utility.
In some instances, the OpCache PHP extension causes this error. To determine if it is the cause, temporarily disable it by changing the cron job to the following command:
php -q -d opcache.enable_cli=0 /path/to/whmcs/crons/cron.php
If the error no longer occurs after making that change, we recommend reverting it and disabling the OpCache PHP extension on the server to resolve this.
Domain renew link in emails is broken
Under some PHP server configurations, the system generates the URL for the domain renewal link in domain renewal reminder emails incorrectly.
You can usually fix this by using the correct PHP binary on your cron job. Alternatively, you can adjust the cron job to work around the issue by formatting your cron command, as in the following example:
cd /path/to/crons/ && php -q cron.php
Could not connect to database
This error occurs when the cron.php script cannot access your MySQL® database. This is often because the PHP configuration that the cron.php script runs under is missing one or all of the following extensions:
- PDO
- PDO MySQL
- MySQLi
It can also be the result of a jailed environment with strict limitations. Your system administrator or hosting provider can check for the required extensions and any environmental limitations by testing a connection to the database and resolving any issues.