Cronjobs using the wrong php version

So on setting up Nextcloud and learning Virtualmin i encountered another problem.

when i run a cronjob for in virtualmin on cron.php for nextcloud this is what i get.

Output from command php -f /home/username/public_html/cron.php …
This version of Nextcloud requires at least PHP 5.6.0
You are currently running 5.4.16. Please update your PHP version.

so i i went into that virtual machine to make sure the php in fact was right. and it was in fact Default HTML directory 7.0.10 there.

So to make sure it infact was running php 7.0.10 i made a phpinfo file and it did in fact show 7.0.10 .

So how can i fix so that cron jobs uses the right php version ?
and why does this happen?

Hmmm…I don’t see any cronjobs created in the Install Script for nextcloud; it looks like nextcloud does it itself. I’ll have to look a little deeper to understand where it comes from. If it’s something we can fix, we will. It might need an upstream fix.

To fix it manually, just edit the cronjob for the domain user (crontab -e) as the user and change the php path. Also, check the shebang line (the #!/usr/bin/php bit) of any nextcloud scripts that are being called from cron to point to the higher version (that’d be /opt/rh/rh-php70/root/usr/bin/php).

Actually, now that I think of it, even if it is a problem upstream, we can probably fix it after installation is completed with a substitution run across any executable scripts. Let me know what you find when you poke around and I’ll ask Jamie what he thinks. Tomorrow I should have some time to do a test install and look at it more closely.

I did find a workaround for it by forcing it to use php7 . by using this

/opt/rh/rh-php70/root/usr/bin/php -f /home/username/public_html/cron.php

then it worked okay it seems. no errors and issues i noticed :slight_smile:

Infact after some running that do only seem to run when pressing run manually. not sure if i maybe should use another php variable rather then -f ???