Finding the right php for cron

In moodle 3.6 there is now a config for path to php.
Look in Moodle Admin. Search for System Paths – Path for php-cli

Typically the path to php-cli is found via:

whereis php

from the command line.

But to see if the one found is php-cli, issue the following command with the
full path as seen in whereis php above.

/path/seen/php -v

If you see anything other than (cli) in the first line,
that’s the wrong one for command line scripts in moodle/code/admin/cli/

Once the path to php-cli is found, one needs to decide how to make that
environment setting for the shell the default.

In home directory of a user using bash shell, there is or should be a .bashrc file (settings for that user in bash).

Add the following line to the end of the document (without quotes):

“alias php=/path/to/bin/php”

(change the PHP path to the one found for php-cli)

nano .bashrc

Juat below the #User specfic aliases and functions comment
which says:

User specific aliases and functions

add the alias.
The example below is not for all systems but an example.

alias php=/opt/cpanel/ea-php70/root/usr/bin/php

Save the .bashrc file. Logout. Log back in.

Test by exeuting php -v

This is what one wants to see **

customerlogin@vmxxx [~]# php -v
PHP 7.0.33 **(cli)** (built: Feb 5 2019 02:28:35) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

The. ‘cli’ above emphsized here with ** in front and ** behind.
You will/should see just (cli).

Perfect! Now all the php scripts in moodlecode/admin/cli/ can be executed
with just php in front … not the path shown in help.

Example:

customerlogin@vmxxx [~/public_html/moodle/admin/cli]# php cron.php

Instead of what is shown to help:

/usr/bin/php admin/cli/cron.php

** if you execute what is shown in help you might get the php meant for the web service.