PHP versions via Cron

LawsHosting

Verified User
Joined
Sep 13, 2008
Messages
2,418
Location
London UK
Guess this one is for feedback.

So, if php_release_1 = 7.4 and the site is set to another version, doing
Code:
php /home/admin/domains/domain.com/public_html/script.php
will be linked to php_release_1 obviously.

I know we can use /usr/local/phpnn/bin/php for the domain's actual php version, but it'll be good to have a button on the /user/cronjobs/create page to fill the Command field/textbox to the domain's set php version......
 
Yes indeed you're quite correct there.
Especially since user are doing mostly copy and paste things which they find on the net for using cronjobs.

Maybe instead of using an option for the user to set it himself, it can be made in such way, that in cron automatically the php version is used which the user has setup, and on php change the cron link will change too.

I don't know if that is possible but it would be good for users.

I wonder how this is done in CP as they ofcourse also have crons for users.
 
Well, the issue with this would be updating every instance of this php binary whenever a user changes PHP.

A "better" solution might be to have a /usr/local/bin/php script that then runs the PHP version for that specific user. A flag would have to be set some where that would signify what version of PHP that user is using. And if no flag is set, then the default PHP version is used.
 
Well, that's kind of the other side of the same coin.

Any time the PHP version is changed, the crontab would have to have it's PATH updated - that's depending on another process to do that.

There's got to be a file or flag set some where any time the user changes their PHP version. Utilize that already existing function result to create a php bash script some where within the $PATH of a user's shell (before any system php binary is found) to lookup that existing file/flag and determine which specific php binary to parse the script through.

Is DirectAdmin already installing a php binary in /usr/local/bin? Maybe add the php bash script into /usr/local/sbin - that's a path that is searched before /usr/local/bin at least it is for me.

You can see what paths are searched by doing an echo $PATH in your shell. The directories are separated with a : when you type any command the shell interpreter will sequentially search through each of those directories for that command until it finds a match and that's the command that it executes. If you type df on the command line, it's going to sequentially look through all of the directories listed in $PATH until it finds a df executable and it will execute that file.
 
Am coding a sports fixture/live score/fixture app and it'll rely heavily on a cron to talk to the API - this made me think about this scenario... I know 7.4 is EOL, my thinking was if the script was written for 8.2, it could fail with 7.4 (or whatever php_release_1 is set to).
 
Back
Top