Php – Nextcloud cron.php timings

cronnextcloudowncloudPHPtimeout

As recommended by Nextcloud Official Documentation, I started to use a system that calls the cron.php every 15 minutes. The call is wrapped in a program that reports errors to me via e-mail and enforces a timeout of 2 minutes on the execution of the cron.php.

Sometimes that the timeout is reached, the wrapper sends SIGTERM and the cron.php exits peacefully – without need for SIGKILL.

It doesn't print anything – not also to the Apache error.log – while doing so. Whenever I check the admin interface, it reports the Cron has been executed recently. The problem occurs roughly once per week.

BTW, I've already had this before switching to Nextcloud.

Is the timeout of two minutes just too low? Or is it a bug? What should I do?

Best Answer

Have you tried activating the DEBUG level in the logs for some time? Please have a look at https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/logging_configuration.html#log-level and set the level to 0.

Then you should see the cron tab describing its action, and you can time the various jobs. Here is an excerpt of a log (from NC version 9 because I did not have to perform such an analysis since migrating to 13, but format should be similar).

{"reqId":"6wulvcxV3RGWrlto+5V0","remoteAddr":"","app":"cron","message":"Run OCA\User_LDAP\Jobs\CleanUp job with ID 16","level":0,"time":"2018-11-08T21:30:02+00:00","method":"--","url":"--","user":"--","version":"9.1.5.2"} {"reqId":"6wulvcxV3RGWrlto+5V0","remoteAddr":"","app":"cron","message":"Finished OCA\User_LDAP\Jobs\CleanUp job with ID 16","level":0,"time":"2018-11-08T21:30:02+00:00","method":"--","url":"--","user":"--","version":"9.1.5.2"}

You can filter the messages with the "app":"cron" value, and separate the requests with the "reqId", then time the duration of a job between the "Run" and the "Finished".

As a final remark, my NC instance goes by the GB, and cron jobs can last way more than 2 minutes. Some of the apps (retention) seriously need SQL optimisation also, otherwise the jobs will last for ages.

cheers, hj