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

Post Reply
User avatar
isscbta
Team Member
Posts: 129
Joined: Mon Jul 19, 2021 1:41 am
Has thanked: 14 times
Been thanked: 3 times

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.

Tags:
Post Reply