With our newer servers, you are able to select which php version you want to use with your cPanel account. This allows you to set the appropriate php version to use with your selected applications. Some versions of applications requires specific php versions. For example, Moodle versions 2.x require php version 5.3.2 and up. While you can set the php version for use within your cPanel, when setting a cron job, it does not automatically use the same version, but relies on the server default. You must adjust your command code to specifically select the php version. Follow along below as we explain how to set your cron job command line to work with the desired version of php.
Forcing the right php version for cron jobs
- Log into your cPanel dashboard.
- From your main cPanel screen, locate the Advanced category. From there, find and click on the cronjobs icon.
- At the bottom of the screen you will see the cron jobs you have set up. Click on the Edit link on the right to edit the command.
- This will display the command line field so you can edit it. In the first part of the cron command, before the path to the script, you will see that it calls php -q. For example, this is the original code for a sample cronjob below:
php -q /home/userna5/public_html/testcron.php
We want to replace the php -q part of the code with /opt/php54/bin/php -q for php 5.3 and above as shown:
/opt/php54/bin/php -q /home/userna5/public_html/testcron.php
or the following for php 5.2:
/opt/php52/bin/php -q /home/userna5/public_html/testcron.php
- After entering your new command line, click the Edit Line button to save the new changes. The chosen cron job will now use your desired php version. Do this for each cron job so they will use the correct php version.
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
new! - Enter your name and email address above and we will post your feedback in the comments on this page!