-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: cron.php executes successfully but Nextcloud says cronjob hasn't run #30899
Comments
I have same problem |
Yes, webcron is known to be unreliable. Please switch to system cron instead! https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/background_jobs_configuration.html?highlight=cron#cron |
Unfortunately the offical Nextcloud docker image does not use the system cron. |
you can either add an addditional container for this: https://github.com/nextcloud/docker/blob/dcf058fb559e7918cd77f5f1bb0dfdbcee813571/.examples/docker-compose/insecure/postgres/fpm/docker-compose.yml#L40-L48 or add a cronjob like this:
|
Any chance you'll update the documentation and remove the feature, or fix the bug? I've been using Webcron for years and it suddenly stopped working in 23.0.3. Had I known it wasn't actually supported I'd have migrated to another solution a long time ago. |
the official helm chart also uses webcron and will need fixed along with the docs |
@szaimen This bug shouldn’t be closed; if a documented feature “is known to be unreliable” then either make it reliable or remove the feature. Leaving it documented and unreliable means it’s just a bug that you don’t want to fix. |
Related #31725 |
As I understand it:
I have the same problem where webcron is executed with status "success", while the "settings" dialog shows that the cronjobs are not being executed -- with my Nextcloud 22.2.6 (docker) instance where I changed from system cron (extra container) to webcron (via health check as suggested by nextcloud/docker#1329 ) in the past month. |
I had this same issue, but it turned out I was really behind on cron jobs after the upgrade, so despite getting I ran the following sql query to check the status of the jobs:
Most of mine had a last_run of 0. So I wanted to see if webcron was doing anything, so i started to curl the cron.php endpoint. After a few minutes of calling it repeatedly it caught up. Now I just need to watch to see if it keeps up or if I need to change the frequency its called. Running the below may help you get caught up on cron's rather quickly. Be careful, this may put some load on your system.
You can run this with a sleep statement to prevent causing too much system load:
I knew I was done when the basic settings page had the green status for background jobs, and all the jobs had a recent last_run in the database. |
@charims I think it will fall behind again. I have a very small instance, system cron finishes quickly, then webcron is green for a while but after a few days it turns red again. Maybe webcron only runs a subset of all the jobs or it keeps failing on the same one but still returns I switched to system cron for now, though I'd rather not, I don't like these cron jobs run by the |
Could it be related to the value of After each successful cron run, the value of lastcron should be updated: Line 180 in 13dbad0
That value determines whether the error message is shown in the UI: The error message related to "Please consider switching to system cron" seems to not depend on a specific outstanding cron task. It seems to rather be based on the date of the last successful cron run. The value of lastcron seems to be fetched for the UI at:
So I'd assume that either their is something that prevents the update of lastcron value or that the retrieval of lastcron for the UI is not working as expected. Could someone who is affected by this try to inspect the lastcron value (not sure where it is stored; maybe in a database table?) and check whether it is updated / fresh? If it is updated/fresh: Maybe there is a problem to get the current value for the UI If it is not updated / not fresh: Maybe there is a problem to persist the change or the line in cron.php is not reached (but then there should some exception be logged according to cron.php code) Checking whether |
Oh, I just realized that I might be wrong with my assumption about lastcron. The error message is based on
Sorry :/ |
I think I found out what is going on. The jobs with time_sensitive == 0 are the ones that won't be executed. has been introduced. server/config/config.sample.php Lines 1238 to 1250 in 396db12
The feature to respect Lines 114 to 144 in 13dbad0
The getNext method of joblist has a new parameter with default = true. server/lib/private/BackgroundJob/JobList.php Line 206 in 13dbad0
server/lib/private/BackgroundJob/JobList.php Lines 215 to 217 in 13dbad0
Webcron fetches job without specifying the parameter, fallback to true default parameter value and will never trigger time_sentitive == 0 jobs Line 170 in 13dbad0
One might want to consider changing the default value for the parameter or to adapt the "else" part of cron.php to consider the new parameter / feature. |
I modified cron.php to handle cron and webcron calls the same way: I will keep an eye on my small docker instance over the next days/weeks. If anyone here feels adventurous, you are welcome to try this out for yourself. If I don't run into problems in the next week, I will open a pull request with this change. |
I wanted to try but ran into a user problem in my webhosted instance: |
I can confirm: Manually changing time_sensitive parameters in DB = 1 immediately triggers all jobs and eliminate the red light in NC configuration menu => „everything OK“ Sadly I don‘t know, what has to be done to change this behaviour. |
i've been running with modified cron.php from @fuse314 for a couple days, it got me caught back up after jobs ran behind again, and now it seems to be keeping up. |
I think #30945 introduced that changes related to |
See my comment in #32107 (comment) |
I've created another #32109 with just default value changed to get any (time-sensitive or not) job from the list. #32107 has been closed but still I don't understand why webcron should not execute time-sensitive jobs only during maintenance hours. I would be grateful for explanation why is that. I understand that this could be just maintainer's will but would be good to have rationale behind the decision. What option is proposed for webcron to run time-consuming jobs during maintenance hours. |
Ill give a more detailed response to that tomorrow from desk. Too hard to put it together on the phone in my free time 😅 |
TL;DR: Only cron is suitable for non-single user instances Background information:
Taking the numbers from the second last point a step further:
On my 2 user home installation I have 64 jobs, but there are no trashbin or version expirations queued, so they would manage to execute all together today. Summary: Using ajax/webcron is only suitable for low-usage instances like 1-2 user home installs with passive sync behaviour. Anything else that requires serious cron execution to deliver notifications, emails, federation, .... must use The breakage with the wrong default value was of course never intended. It's fixed now and will come with the next updates to 23 and 22 I assume. |
Also send a pull request to update the documentation on that a bit: |
@fuse314, your repo change to |
The webcron solution is notable not working for me in 24.0.5, not sure if it just fell behind and never caught up or if it is still fundamentally unable to handle the load. (Low user-count in my case.) My workaround is unfortunately to configure my synology to run |
Bug description
I saw this message:
Background jobs Some jobs didn’t execute since yesterday.
Please consider switching to system cron.
Steps to reproduce
3 cron being run by webcron
Expected behavior
The cron has seemingly run successfully, so I should not see this message in the UI? Can't see any issues in the Nextcloud log either.
Installation method
Official Docker image
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.0
Web server
Apache (supported)
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
Webcron container:
Image: curlimages/curl:7.81.0
Cron Schedule: */5 * * * *
Command: curl -L -s https://nextcloud.ltd/cron.php
Result: {"status":"success"}
When I run cron.php manually inside the container it is successful (sudo -u www-data PHP_MEMORY_LIMIT=512M php /var/html/cron.php)
The text was updated successfully, but these errors were encountered: