InMotion Hosting Support Center

In all but our oldest servers, we have implemented a feature that allows you to chose what version of php you want to use on your account. While this works well for files running normally for your site, it will not work for cron jobs. Cron jobs will use the default php for the server if set up as directed in our article on How to run a cron job. You will need to specifically identify the php version 'switch' to have the cron job use that version for running your scheduled scripts. Below is a set of instructions that will guide you on how to edit the cron job command to use the specific switch.

How to force a specific php version for cron jobs

  1. First, log into your cPanel dashboard.
  2. Now that you are in the main cPanel area, find the Advanced category and click on the Cron Jobs icon.
  3. 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.

  4. 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/php54/bin/php -q) for php 5.3 and above:
    /opt/php54/bin/php -q /home/userna5/public_html/cronscript.php
    or (/opt/php52/bin/php -q) for php 5.2 as shown:
    /opt/php52/bin/php -q /home/userna5/public_html/cronscript.php
  5. Enter the new code at the beginning of the command, then click the Edit Line button to save it. This cron job will now use your correct php version. You will need to do this for each cron job so that they are certain to use the correct php version.
Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

2017-09-25 2:23 am
Is this still valid? I'm getting error in cron and from shell cli when I try the examples above and my specific instance: /opt/php56/bin/php -q /home/askwino7/winelabnet/WHMCS/crons/cron.php

1,173 Points
2017-09-25 2:31 pm

Yes it is still valid however the path may be different depending on the version of EasyApache on your server and the PHP packages being used. If you are using a fresh install of EasyApache4 your PHP will be located at /opt/cpanel/ea-phpXX/root/usr/bin/php. So if you wanted to execute it with 5.6 you would use /opt/cpanel/ea-php56/root/usr/bin.

Best Regards
Kyle M
n/a Points
2018-03-17 9:51 am

How can you verify which version of EasyApache is running on a VPS without root access?

10,768 Points
2018-03-19 10:20 am
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.

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

4 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!