Why does cron.php change owner?

A few days ago I reinstalled Nextcloud. In System Settings > General Settings, I learned that cronjobs should be executed by root.

But this evening I logged in, only to get an error message (that I didn’t save), but it turned out cronjobs had stopped and now suddenly needed to be executed by www-data.

I noticed that cron.php had root:www-data ownership, something I don’t recall seing before.

Why does that happen?

Thanks and happy holidays, all!

Unsure where you read this, but Nextcloud uses www-data. Here is the documentation:

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/background_jobs_configuration.html

Nextcloud will tell you which user should run cron.php under System Settings > General Settings

Everything worked fine with root, until something changed and www-data took over.

The cronjob is being executed as expected. But I’m just curious as to why this change happened.

It depends entirely on how you’ve installed Nextcloud Server and what user you’re running it under.

Conventional deployments typically end up using www-data but that varies for all sorts of reasons. It’s not determined by Nextcloud but by how you’ve installed things.

The check under Admin->Basic Settings just tells you what user you appear to be running your web app’s under. And cron must match that.

1 Like

The web interface simply shows you the username of the owner of cron.php, which it reads from the file system metadata.

So If the cron.php is owned by “www-data”, the web interface says “www-data”. If the file is owned by “I-changed-the-ownership-to-another-user-although-I-probably-shouldn’t-have”, it says “I-changed-the-ownership-to-another-user-although-I-probably-shouldn’t-have”. :wink:

Not sure, maybe after a Nextcloud upgrade? Anyways, www-data, i.e. the web server user, is generally the appropriate owner, and it probably should never have been root in the first place.

2 Likes