Add the php binary path to cron PATH

Version 1.561


April 9th: UPDATE: bug with this feature. Changed default to: set_php_bin_path_in_crons=0 where $PATH varible is not valid in crons, making PATH=/anything/:$PATH invalid. 1.56.2 should released shortly today with a fix. -------------- Clients will often try to use "php" in their cron commands. It's recommended that they use the full path, which is guaranteed to exist: /usr/local/bin/php However, with the php selector, their website is allowed to use the 2nd (or 3rd, 4th) php version. Using /usr/local/bin/php would only use the 1st php version. This feature would automatically set the cron PATH to be (for example): PATH="/usr/local/php71/bin:$PATH" New internal default directadmin.conf value, enabled by default: set_php_bin_path_in_crons=1 to disable, add this to the directadmin.conf and restart directadmin: set_php_bin_path_in_crons=0 If they've chosen php 7.1 on their default domain. This lets them use "php", which should be found.. and also is more portable, since you can change php versions, and it should update the cron PATH automatically. This way, both the website and it's related cronjobs use the same php version. ========== LOGIC DirectAdmin will only set the path to include /usr/local/phpXX/bin in certain scenarios. One of: 1) PATH is currently empty, or blank 2) PATH already has /usr/local/bin/phpXX, but *must* be first in the list. if none of the above are true, then DA will not set, nor update the list. For example, DA will not touch this, if it's set: PATH="/usr/local/bin:/usr/local/php72/bin:$PATH" PATH="/usr/local/bin:$PATH" PATH="$PATH" because /usr/local/phpXX is not first in the list. However, if you have any of: PATH="" PATH="/usr/local/php72/bin:$PATH" PATH="/usr/local/php72/bin:/any/other/list/of/paths:$PATH" PATH="/usr/local/php72/bin:/any/other/list/of/paths" Then anytime the User changes their selected php version at: User Level -> Domain Setup -> -> php selector DA will swap this first php72 value with the newly selected php version. ========== NOTE: Because cronjobs are per-User, and not per-Domain, only 1 php path can be used.. hence we've opted to set the php version PATH to that of the main/default domain of the User account. If a 2nd domain requires some other php version, the client can manually specify it, eg: /usr/local/php72/bin/php instead of "php". Not done: Also add to /home/username/.bashrc for ssh (if it's clean enough to do so) T14525

Interested to try DirectAdmin? Get a 30-day Free Trial!