CLI cron task issues (.ocdata)

Nextcloud version (19.0.1):
Operating system and version (CentOS 7):
Apache or nginx version (Apache 2.4.6):
PHP version (7.3.21):

Hello everyone ! I’ve been using Nextcloud for a year now, never got any particular issue that I coudn’t solve. I need help on this one.

So I was doing a migration from a drive to another one and somehow, everything messed up. (even my backup…).
On the admin account, when I check the server overview, I have this error :

It was not possible to execute the cron job via CLI. The following technical errors have appeared:
Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.
Your data directory is not writable

It’s the first time I get this error, even if I moved already the data folder in the past. I’ve done some search on the forum but no answers could fix my issue.

So I checked the .ocdata in my data folder :
Rights : rw-r–r--
User:group : apache:apache
For this one I think it’s related to the second issue.

When I check the data folder :
Rights : rwxrwx—
User:group : apache:apache

I don’t know what do I need to check more…
The cloud is working, I can read files and upload too. I have the errors but it’s working “fine” I just fear side effects or invisible issues.

For some reason my Admin logs don’t work anymore (infinite spin)

config.php file

$CONFIG = array (
  'passwordsalt' => '---',
  'secret' => '---',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '192.168.X.X',
    2 => 'my_domain_name',
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_nextcloud',
  'dbpassword' => '---',
  'installed' => true,
  'instanceid' => '---',
  'overwritehost' => 'my_domain_name',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'https://my_domain_name',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'updater.secret' => '---',

No errors related in error.log in my apache log folder.

I can provide more informations if needed.

Thanks for your answers.


Hi ! Anyone can help me on this ? I still can’t find what cause this issue, even with the 19.0.2 update

I had the same issue on 19.0.1 and 19.0.2, in my case it had nothing to do with incorrect permissions. I can let you know what I did to fix it, but no guarantee it’ll work for you.

First go to “basic settings” and choose “Cron” for the background tasks.

There is no need to set up a cron job or anything, just run the cron script manually at a terminal, from within your nextcloud directory. Use a command like the following -:

sudo -u apache php -f cron.php

If you go back to your browser, and reload the basic settings page, it should mention the last cron job was done seconds ago. Now switch back to “AJAX” for background tasks on the same page. Go back to your “overview” page and hopefully the issue is gone.

Thanks you very much alvinde. It worked !
If anyone get the same error as me, just do the following up there.