Page 1 of 1

How to change the PHP version for PHP scripts running with CRON

Posted: Fri Aug 12, 2022 12:27 pm
by isscbta
For example, let's say that domain.com's predefined PHP version is 7.4, but you want to ensure that all PHP scripts running through CRON use also PHP 7.4.

Instead of:

Code: Select all

php /home/USER/web/domain.com/public_html/somescript.php
your CRON command should be written like this:

Code: Select all

php7.4 /home/USER/web/domain.com/public_html/somescript.php > /home/USER/php_cron.log 2>&1
So, instead php just write php7.4 or other desired version of PHP.