Cronjob hasn't run for 7 days. Ownership issue?

Nextcloud version: 29.0.5
Operating system and version : Ubuntu Server 22.04 LTS
Apache or nginx version: Apache 2.4.52
PHP version : 8.1


Got the warning: " Some jobs have not been executed since 7 dage siden. Please consider increasing the execution frequency. "

Which was surprising, because cronjobs have been running smoothly up until now.

I suspect the issue began with this: Some days ago I got an error message about not being able to write to config.

I read:

https://docs.nextcloud.com/server/stable/admin_manual/maintenance/manual_upgrade.html

and solved it thus:
cd /var/www; $ sudo chown -R www-data:www-data nextcloud

However, I missed that config.php is now owned by www-data. This is confirmed in Basic Settings:

Image description: “The cron.php needs to be executed by the system account www-data”.

I’m positive that cronjobs used to be executed by root. The cron.php job is even in the root crontab.

I removed the job from root and added it to www-data:

sudo crontab -u www-data -l
*/5  *  *  *  * /usr/bin/php8.1 --define apc.enable_cli=1 -f /var/www/nextcloud/cron.php

No change. The warning persists.

Running the job from the command line returned no errors, but also didn’t remove the warning.

Changing ownership of the config folder back to root would probably not work?

Not sure how to proceed. Any help is appreciated.

Is this the first time you’ve seen this error? Yes.

Admin > Logging:

{"reqId":"8PVprTBIYMKMGLxF1deZ","level":3,"time":"2024-08-27T19:15:44+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"GET","url":"/settings/admin","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0","version":"","data":{"app":"PHP"}}
{"reqId":"3NwPntpxAoE6Xc28nTaB","level":3,"time":"2024-08-27T19:15:45+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"GET","url":"/index.php/apps/files/preview-service-worker.js","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0","version":"","data":{"app":"PHP"}}
{"reqId":"7K7aqhmR88NxlUvk1BIM","level":3,"time":"2024-08-27T19:15:49+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"GET","url":"/settings/admin","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0","version":"","data":{"app":"PHP"}}
{"reqId":"f4oNmc6JdYMIHTPFOrUM","level":3,"time":"2024-08-27T19:15:50+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"GET","url":"/index.php/apps/files/preview-service-worker.js","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0","version":"","data":{"app":"PHP"}}
{"reqId":"uo30vXUuKuD7Rng058ZJ","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/something","message":"Error: Class \"OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin\" not found at /var/www/nextcloud/remote.php#62","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}
{"reqId":"uo30vXUuKuD7Rng058ZJ","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/something","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}
{"reqId":"rPcz698WlSBQL5dEUPOg","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/something","message":"Error: Class \"OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin\" not found at /var/www/nextcloud/remote.php#62","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}
{"reqId":"rPcz698WlSBQL5dEUPOg","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/something","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}
{"reqId":"wAOaOnn2MdK1VJomWsXq","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/Dokumenter","message":"Error: Class \"OCA\\DAV\\Connector\\Sabre\\ExceptionLoggerPlugin\" not found at /var/www/nextcloud/remote.php#62","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}
{"reqId":"wAOaOnn2MdK1VJomWsXq","level":3,"time":"2024-08-27T19:15:58+00:00","remoteAddr":"xx.xx.xx.xx","user":"--","app":"PHP","method":"PROPFIND","url":"/remote.php/dav/files/something/Dokumenter","message":"fopen(/var/www/nextcloud/config/config.php): Failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Config.php#221","userAgent":"Mozilla/5.0 (Linux) mirall/3.13.2git (Nextcloud, fedora-6.10.6-200.fc40.x86_64 ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"","data":{"app":"PHP"}}

cat /var/logs/syslog:

Aug 27 19:20:01 nextcloud CRON[119965]: (www-data) CMD (/usr/bin/php8.1 --define apc.enable_cli=1 -f /var/www/nextcloud/cron.php)
Aug 27 19:20:03 nextcloud CRON[119963]: (CRON) info (No MTA installed, discarding output)
Aug 27 19:20:29 nextcloud crontab[119971]: (root) LIST (www-data)

Looks normal?

Earlier in the log, I see that cron.php used to be executed by root:

Aug 27 17:40:01 nextcloud CRON[100621]: (root) CMD (/usr/bin/php8.1 --define apc.enable_cli=1 -f /var/www/nextcloud/cron.php)
Aug 27 17:40:01 nextcloud CRON[100619]: (CRON) info (No MTA installed, discarding output)
Aug 27 17:40:03 nextcloud CRON[100618]: (CRON) info (No MTA installed, discarding output)

What happens if you execute the cron.php manually?

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

Are you sure PHP 8.1 is installed on this server? Ubuntu 24.04 ships with PHP 8.3 by default…

What’s the output of:

update-alternatives --query php
2 Likes

It looks like a normal execution. I piped the command to look for potential output:

sudo -u www-data /usr/bin/php8.1 -f /var/www/nextcloud/cron.php | tee cronjob-output.log

Nothing. Empty logfile.

Regarding PHP:

$ php -v
PHP 8.1.2-1ubuntu2.18 (cli) (built: Jun 14 2024 15:52:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.18, Copyright (c), by Zend Technologies

Not sure why I have 8.1. I could have been installed during the Apache2 installation. As far as I know, php 8.1 is still supported by NC, so I guess the nextcloud installer decided to ignore it?

$ update-alternatives --query php
Name: php
Link: /usr/bin/php
Slaves:
 php.1.gz /usr/share/man/man1/php.1.gz
Status: auto
Best: /usr/bin/php.default
Value: /usr/bin/php.default

Alternative: /usr/bin/php.default
Priority: 100
Slaves:
 php.1.gz /usr/share/man/man1/php.default.1.gz

Alternative: /usr/bin/php8.1
Priority: 81
Slaves:
 php.1.gz /usr/share/man/man1/php8.1.1.gz

Are you sure you are on Ubuntu 24.04 and not 22.04?

Well, the PHP version itself is certainly not the root cause of your problem, although you might want to think about updating it soon, as PHP 8.1 is officially deprecated with Nextcloud 30. However, if you are actually running Ubuntu 24.04, I would find it odd that you are still on 8.1, unless you explicitly installed that version from a third party source.

Also, I’m not sure why the link to the default version has a .default extension. Normally the default would be /usr/bin/php, and then there are explicit ones for each version you have installed, /usr/bin/php8.1, /usr/bin/php8.2 etc…

What’s the output of:

which php

…and what happens if you run the command as follows:

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

Okay, now I’m puzzled. I ran your cronjob manually and without prepending it as you suggested. And I thought it was actually working.

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

But while writing a congratulary note, I noticed the job had updated on its own. I have monitored the update for half an hour. Cron.php seems to be running normal. And I have made zero changes since posting the original question.

I have no idea why this changed.

But thank you for taking the time to help me out. It is much appreciated!

Here’s the rest of the info you requested, just the same:

$ which php
/usr/bin/php

I’ll be upgrading php sometime soon. I just wanted to close one issue before opening another :-/

And no, I’m not on 24.04 but 22.04. Thanks for pointing that out. I’ve updated the original post accordingly.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:        22.04
Codename:       jammy

Thank you again.

1 Like

Glad it works now, even if we don’t know exactly why :wink:

Oh, and regarding the PHP update, I wanted to mention that one of the forum moderators maintains a script that might help you with this:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.