Cron job won't work. v25.0.4. Really struggling here

Ok, I think we’ve waited enough. I got cron set since your last post 11 mins ago, and now NC web interface keeps telling me that the last background job was performed just 2 or 3 minutes ago. This is a big change from how it was before. Before it never performed a background job when set on Cron. Only on AJAX.
So … time for CLI check?

Yes. Now time to ensure memcache is correctly setup.

Interested to understand this better. The command “OCC” is not immediately applicable in Ubuntu’s command prompt, so I’m assuming this is not the “Window” you’re talking about?
The only other OCC reference I know of is the Web App in Nextcloud called OCC Web. This one opens up a simple prompt. Is this the Windows you’re referring to, where I can change the loglevel in?

I think I could try this, at the right time, and see what comes out. :slight_smile: I am not new to the computer world, but I’m rather fresh on Linux and Nextcloud. This is really interesting, and challenging.

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

OCC is the CLI application in nextcloud. The name has not changed since the fork from OwnCloud, so it should have been called NCC, but that is a different matter entirely. OCC has to be called with php as well, and from full path in your NC installation. Different matter, and loads of community threads on this. Let us focus to solve your issue first.

First just try to add this at the end of your cron config:

*/5 * * * * php -f /var/www/nextcloud/cron.php --define apc.enable_cli=1

And activate memcache config in config.php again.

Done, and restarted Apache2 …

You can create ncc as an alias in your ~/.bash_aliases file:

alias ncc='sudo -u www-data /usr/bin/php -f /var/www/nextcloud/occ'

:wink:

Good. We probably should just have tested it with the command you did before to save some time. But fair.

Yeah but it would just stress me out when I reads documentation and stuff. I was referring more generally speaking… :slight_smile:

Btw what is the CLI? the manual got many references but no clear definition or explanation. I’m assuming it’s not as simple as Command Line Interface.

Well it is build-for-purpose command line interface for many maintenance tasks. It is also the interface to use for automating upgrades, app upgrades, recovery attempts, more advanced and complex user administration tasks, re-build indices, cleanup database etc etc.

This is my oneliner (crude example) for updating all apps from linux command line:

sudo -u www-data php8.1 /var/www/nextcloud/occ app:update --all

This is just the top of the list of available commands:


Ah, a second-level interface just for Nextcloud. Nifty. :slight_smile:
So, how does the addition of the …

–define apc.enable_cli=1

… code play into this? To my naked eye it appears to enable the CLI for … memory APC reasons/tasks?

Because the backgroundjobs maintains your indices and your cache. APCu and redis (if you will later use that) is maintained by the backgroundjobs, so if the cronjob cannot access the needed php modules or they are not configured correct, it will not be able to do much for you. So the APCu needs to be enabled for CLI.
However just add this excact line at the bottom of your php8.1 ini file:
apc.enable_cli=1
And you do not need that addition in the cron.

Got it. Done.
And after this, I will need to check that all necessary PHP modules (for this) are installed, and possibly revise their configurations?

If you do not have any errors after this, you do not need more. However as you expands your solution or when you decides to go fully into it, I recommend to use NGINX, PHP-FPM, Redis and Postfresql and utilize OCC interface much more. Then you will have much to configure. Initially. After that? You will never look back. :slight_smile:

Sounds exciting. However it’s too big of a bite to chew for me at this time, I feel.
I just learned how to get it up and running well :slight_smile: Appreciate the suggestions.

So … how did this problem of mine occur then, most likely? Are there potentially some php modules that I failed to configure correctly? Possibly due to some shortcomings in the guide I used?

Nope. You followed a guide and activated APCu, however the documentation of Nextcloud has some hints about potential challenges and things to be vary about when starting going down line of adding more than the core of it.

https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#id1

Aha, there it is in plan text: “APCu is disabled by default on CLI which could cause issues with nextcloud’s cron jobs. Please make sure you set the apc.enable_cli to 1 on your php.ini config file or append --define apc.enable_cli=1 to the cron job call.”

So, turns out the APCu is NOT the default method of handling indices and cache? And I was under that impression, lacking any other knowledge or alternatives, and following a guide with a slight bit or ‘personality’ to it. APCu needs specific enabling to work well with PHP and cron jobs.

I did however recall setting up opcache, and scratching my head a bit about what would be the difference between that and APCu. Perhaps I should’ve scratched a bit harder.

Do not be fooled in regards to the many caches and what is default and not.
OPCache is caching of PHP code. ACPu is memory cache of static files (JS, HTML etc) and files on filesystem (however not the best).

PHP does not, per say, has anything default. There is extensions and modules. Nextcloud is a PHP application, so whatever PHP is supporting, or whatever is possible with PHP, is what Nextcloud supports.

Redis is a much more powerfull file and memory caching application, which is not a PHP module only. Redis offers PHP modules as well as modules for many other languages, operation systems, databases and so on. It has a lot of features that Nextcloud can benefit from which APCu can never match. However APCu is the most lightweight and fastest to implement as it requires almost no extra config.