How to find out why cron.php takes so long and what it is woking on?

I have a NC 28.0.12 instance (→ without the Recognitize app) running bare metal on a home server (NUC, i7 mobile processor, plenty of RAM, local NVMe storage). All day it is quiet, even when accessed heavily.

Yet, every night, its fan suddenly is on full speed, for approx. 40 minutes. Every night, no matter whether files were changed or not during that day. Then, ps ax yields php -f …/cron.php. Using lsof -p PID, I see that it had …/__groupfolders/versions/NUMBER open.

Questions:

  1. Are there better ways to see which tasks cron.php performs, and how long they take?
  2. Are 40 minutes a reasonable time for the daily cron for a system such as the following figures depict?

occ versions:cleanup (for 121 users) only takes a few seconds


occ groupfolders:scan --all takes 2 minutes

+----+------------+-------+----------+
| Id | Groups     | Size  | Adv.Perm |
+----+------------+-------+-----------
| 2  | 1: r/w/s/d |  7 GB | Disabled |
| 6  | 2: r/w/s/d |  4 GB | Enabled  |
|    | 1: r/w/s/d |       |          |
| 10 | 3: r/w/s/d | 13 GB | Disabled |
|    | 1: r/-/-/- |       |          |
|    | 6: r/w/s/d |       |          |
| 12 | 5: r/w/s/d | 20 GB | Enabled  |
| 13 | 1: r/w/s/d | 16 GB | Enabled  |
| 20 | 1: r/w/s/d | 20 GB | Disabled |
+----+------------+-------+----------+

occ files:scan --all takes 5 minutes

+---------+--------+-----+---------+---------+--------+--------------+
| Folders | Files  | New | Updated | Removed | Errors | Elapsed time |
+---------+--------+-----+---------+---------+--------+--------------+
| 38000   | 250000 | 0   | 480000  | 0       | 0      | 00:05:00     |
+---------+--------+-----+---------+---------+--------+--------------+

I also don’t quite understand what the “Updated” figure means here: More updates than files?

If you can manually check the oc_jobs table, you can have a look which job takes how long to run (should be in seconds) and when it was run for the last time.

Why it is taking longer at night:
https://docs.nextcloud.com/server/28/admin_manual/configuration_server/background_jobs_configuration.html#parameters

oc_filecache is a file index, it can exceed the number of actual files. I’m not 100% sure which one, among shared files, different versions, deleted files, there might be several entries per file. Also appdata, previews, …

That looks like the Group Folders specific versions expiration manager. It could be the culprit or just may be that you’re seeing it since it’s a frequent job. It runs every hour.

You can run its command counterpart (occ groupfolders:expire) to see if anything looks odd.

Yet, every night, its fan suddenly is on full speed, for approx. 40 minutes.

This sounds more like a job that is set to run during your maintenance_window_start.

Apps can declare select background jobs that are likely to generate a heavy load and/or are time insensitive. Those will run during the configured maintenance_window_start.

Is it during that time window?

For the record, the group folders versions expiration is not one of these.

The commands occ background-job:list and occ background-job:execute might be helpful.

This is all assuming it’s Nextcloud and not something OS level. :slight_smile:

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