ALL SYSTEMS OPERATIONALUPTIME 99.97%FLEET 18/18IN-MUM · US-LAX · EU-FSN EST. 2003 · +91 11 4998 4038

KNOWLEDGEBASE · PHP ENVIRONMENT

How to Set Up or Force Cron Jobs to Use a PHP Version

Last updated 2023-04-07

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 command code for the sample cronjob is displayed below will be executed using the system PHP version set for the server:

 

php -q /home/userna5/public_html/crondir/cronscript.php

 

 

To execute the sample cronjob using a specific PHP version line say PHP version 7.4 available through 'Select a PHP version' or PHP Selector, change the command to

 

/opt/alt/php74/usr/bin/php -q /home/userna5/public_html/crondir/cronscript.php

 

 

To execute the cron using PHP 5.6 instead, replace the 74 in /opt/alt/php74/usr/bin/php with 56 to format the sample cron as

 

/opt/alt/php56/usr/bin/php -q /home/userna5/public_html/crondir/cronscript.php

← All knowledgebase articles

Tell us what has to stay up.

A short conversation with an engineer. No quote-bot, no callback queue. We'll tell you honestly if we're not the right fit.