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->

construct()
#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!

@Kerasit @ajay69 @Palerm : I have precisely this same problem it seems. I have been able to follow all suggestions in this thread, and I still get no success. Cron for background jobs just will not execute. Ajax though works fine.

I’m on v25.0.4 Ubuntu server 22.10.

Only fail I can see so far, that might be adressed, is I keep getting instructions to write the cronjob file as:
*/5 * * * * /usr/bin/php8.1 -f /var/www/nextcloud/cron.php

However there is no folder called “php8.1” in /usr/bin/ directory. There’s just a file called php8.1, but no folder. Makes me suspect something might’ve turned out bad with the php installation. However everything else on the server works 100%, tried it out pretty good.

I have also tried writing the cronjob in many different variations, like:
*/5 * * * * php -f /var/www/nextcloud/cron.php
*/5 * * * * php8.1 -f /var/www/nextcloud/cron.php
etc and I reboot the computer each time and wait at least 15 minutes before checking if it works. And yes I have changed the sudo update-alternatives option described above.

So I’m not sure what to make of it, and I have no further options to try from now :confused:
Would really appreciate some educated suggestions.

Are you using Docker, NCP, VM AIO, self installed?

How do you opens your crontab?

Have you tried executing the cron.php manually at least once like:

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

Please, we needs a little more info to help you.

@Kerasit . Thank you for offering help. :slight_smile:
I decided to create my own thread about it, where I outline alot of what I have done already.
If you care to check in there: