In all but our oldest servers, we have implemented a feature that allows you to set a version of PHP you want to use on your account. However, cron jobs running on a server will normally use the PHP version set for the server, and not the one specified by the PHP version tool. If your cron job needs to run with a different version of PHP, then you will need to specify it in your cron job command or script.
The need to force cron jobs to use a PHP version is especially important for some application-specific cron jobs from software like WHMCS.
The cron PHP version mismatch error is a common error in some applications that will require you to specifically identify the PHP version ‘switch’ for your cron jobs. You will see an example of the PHP Version mismatch error and how to edit the cron job command to use the specific switch leading to the needed PHP version.
Looking for a new WordPress hosting solution? Check out InMotion’s WordPress Hosting servers for secure, performance-oriented solutions for your hosting needs.
Common Cron Job Error – Cron PHP Version Mismatch
Typically, this error occurs when there are multiple software being used on a hosting server. The PHP version switcher allows you to specify a newer version of PHP to be used with the website. However, the cron jobs for the software may be using the PHP version configured specifically to the server. This leads to the PHP version mismatch error. You can fix the error by simply forcing the cron job to use a specific PHP version.
This is a commonly reported error with the WHMCS application. You may first see a warning about the PHP version that looks something like this:
This can often lead a person to upgrade their PHP version on their website, but the upgrade can lead to this error:
In this case, the website is using the newer version of PHP, but the cron jobs are using an older PHP version configured for the server by default. If you see this error, then you will need to set your cron job to use a specific version of PHP. The steps to force cron jobs to use a specific PHP version are described in the next section.
Force Cron Jobs to use a PHP Version
Follow the steps below in order to force your cron job to use a specific PHP version.
- First, log into your cPanel dashboard.
- Find the Advanced category and click on the Cron Jobs icon.
- This takes you to the cron job set up page. At the bottom of the screen you will see the cron jobs you have currently scheduled. Click on the Edit link on the right to edit the cron command.
- You will now see the command line field so you can edit it. The cron command is in two parts, the first part calls the PHP and the second part is the path for the script you want to run.
The command code for the sample cronjob is displayed below:
php -q /home/userna5/public_html/cronscript.php
We want to replace the first part of the code (php -q) with (/opt/php74/bin/php -q) for PHP 7.4 and above:
/opt/php74/bin/php -q /home/userna5/public_html/cronscript.php
or (/opt/php72/bin/php -q) for PHP 7.2 as shown:
/opt/php72/bin/php -q /home/userna5/public_html/cronscript.php
Enter the new code at the beginning of the command, then click the Edit Line button to save it. The cron job will now use the correct PHP version. You will need to do this for each cron job so that they are certain to use the correct PHP version.
You should now be able to recognize the common PHP version mismatch error and force cron jobs to use a PHP version that can fix the error.
Say goodbye to slow loading times and hello to high-performance websites with our new WordPress VPS Hosting plans. Experience 40x faster WordPress page load speeds on purpose-built servers that guarantee 99.99% uptime.
High-Performance VPS Fully-Managed Support Free SSL & Dedicated IP Advanced Server Caching
Should update cron include path for php 7.x
How can you verify which version of EasyApache is running on a VPS without root access?
Root access is required. However, if you’d prefer not to use your root access privileges, you can always contact our live support team. They can confirm the version information with you.