Cron.php not executable after installation of Nextcloud 25 with php 8.1

Nextcloud version (eg, 20.0.5): 25
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.54
PHP version (eg, 7.4): 8.1

The issue you are facing:
After fresh install with of Nextcloud 25 with Apache 2.4.54/php8.1 executing the cron.php via cronjob isn’t possible anymore. Some general php-setting in Apache seems to state php 8.2 which I actually avoided when installing php.

After executing
php -f /var/www/nextcloud/cron.php

the error message is:
“This version of Nextcloud is not compatible with PHP>=8.2.
You are currently running 8.2.0.%”

Any ideas how I can tell the system that php8.1 is still available and supposed to be used for that job?

Is this the first time you’ve seen this error? (Y/N): Y

Maybe this:

1 Like

php -f /var/www/nextcloud/cron.php

This executes the PHP CLI application with the given php file (crom.php).
However you have not explicitly choosen which php version to use, hence asks the system to use the PHP version of its choice (PHP is an alias which the system translates to the newest installed PHP CLI version on the host system). Usualy this is the newest version installed.

Try specify the version:

php8.1 -f /var/www/nextcloud/cron.php

1 Like

Thanks a lot! Highly appreciated.

I think I had tried that and got an error message which I can’t remember. I retried it and now I get the following feedback:
Cannot load Zend OPcache - it was already loaded
ArgumentCountError: Too few arguments to function OCA\MediaDC\BackgroundJob\CollectorCleanupJob::construct(), 0 passed in /var/www/nextcloud/lib/private/BackgroundJob/JobList.php on line 304 and exactly 2 expected in /var/www/nextcloud/apps/mediadc/lib/BackgroundJob/CollectorCleanupJob.php:41
Stack trace:
#0 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(304): OCA\MediaDC\BackgroundJob\CollectorCleanupJob->

#1 /var/www/nextcloud/lib/private/BackgroundJob/JobList.php(243): OC\BackgroundJob\JobList->buildJob()
#2 /var/www/nextcloud/cron.php(145): OC\BackgroundJob\JobList->getNext()
#3 {main}

at least some other behaviour now

Cannot load Zend OPcache - it was already loaded

Just ignore this.

If you are trying to execute the command manually, remember top do so as www-data user.

sudo -u www-data php8.1 -f /var/www/nextcloud/cron.php

When setting up in crontab, remember to setup crontab for the user www-data

sudo -u www-data crontab -e
# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command
*/5 * * * * php8.1 -f /var/www/nextcloud/cron.php

As example.

1 Like

Yep, that did the job. Again thanks a lot! Problem solved.

Side note: don’t use the nano-editor in the terminal interface of Cockpit. Ctrl-O doesn’t let you save the file but wants to open a file :smiley:

Sorry, forgot to reply to this.

Sounds indeed like the problem I faced and once I change it in “sudo update-alternatives” to php8.1, it uses it.

Perfect, 1 problem, 2 solutions :wink:

Many, many thanks!