Data directory is not writable by cronjob but it is

Hi,

EDIT: As I typing this report the issue has gone. Maybe I need to run the cron sudo -u nginx php -f /var/www/nextcloud/cron.php once? I don’t know. I’ll have an eye on that.

Nextcloud version (eg, 20.0.5): 20.0.8
Operating system and version (eg, Ubuntu 20.04): alpine linux 3.13
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18.0
PHP version (eg, 7.4): 7.4.15

The issue you are facing:

my NC says the cronjob can’t success because the data dir is not writable.
But it is writable:

neptun:~# ll /mnt/
total 12K    
drwxr-xr-x    3 root     root        4.0K Mar  3 12:07 .
drwxr-xr-x   20 root     root        4.0K Mar  3 12:44 ..
drwxrwx---    8 nginx    nginx       4.0K Mar  3 12:09 data
neptun:~# ll /mnt/data/
total 42M    
drwxrwx---    8 nginx    nginx       4.0K Mar  3 12:09 .
drwxr-xr-x    3 root     root        4.0K Mar  3 12:07 ..
-rw-r--r--    1 nginx    nginx        542 Feb 25 10:27 .htaccess
-rw-r--r--    1 nginx    nginx          0 Feb 25 10:27 .ocdata
drwxr-xr-x   13 nginx    nginx       4.0K Nov 24 15:39 appdata_ocbqiu3jjvdd
-rw-r--r--    1 nginx    nginx          0 May 26  2020 audit.log
drwxr-xr-x    2 nginx    nginx       4.0K Feb 25 10:27 files_external
-rw-r--r--    1 nginx    nginx          0 Feb 25 10:27 index.html
drwx------    2 nobody   nobody     16.0K Mar  3 12:07 lost+found
-rw-r-----    1 nginx    nginx      41.3M Mar  3 13:20 nextcloud.log
drwxr-xr-x    4 nginx    nginx       4.0K Apr 22  2020 opnsense
drwxr-xr-x    4 nginx    nginx       4.0K Feb 25 10:27 updater-ocbqiu3jjvdd
-rw-r--r--    1 nginx    nginx     214.7K Feb 25 10:27 updater.log

I’m using nginx and the data dir is at /mnt/data.
Here are the www dir:

neptun:~# ll /var/www/
total 16K    
drwxr-xr-x    4 nginx    nginx       4.0K Feb 10 02:28 .
drwxr-xr-x   13 root     root        4.0K Feb 10 00:43 ..
drwxr-xr-x    2 nginx    nginx       4.0K Feb 10 01:52 adminer
drwxr-xr-x   14 nginx    nginx       4.0K Feb 25 10:24 nextcloud
neptun:~# ll /var/www/nextcloud/
total 168K   
drwxr-xr-x   14 nginx    nginx       4.0K Feb 25 10:24 .
drwxr-xr-x    4 nginx    nginx       4.0K Feb 10 02:28 ..
-rw-r--r--    1 nginx    nginx       3.0K Feb 25 10:27 .htaccess
-rw-r--r--    1 nginx    nginx        101 Feb 25 10:23 .user.ini
drwxr-xr-x   41 nginx    nginx       4.0K Feb 25 10:24 3rdparty
-rw-r--r--    1 nginx    nginx      16.8K Feb 25 10:23 AUTHORS
-rw-r--r--    1 nginx    nginx      33.7K Feb 25 10:23 COPYING
drwxr-xr-x   52 nginx    nginx       4.0K Feb 25 10:24 apps
drwxr-xr-x    2 nginx    nginx       4.0K Mar  3 13:09 config
-rw-r--r--    1 nginx    nginx       3.8K Feb 25 10:24 console.php
drwxr-xr-x   22 nginx    nginx       4.0K Feb 25 10:24 core
-rw-r--r--    1 nginx    nginx       5.0K Feb 25 10:23 cron.php
drwxr-xr-x    2 nginx    nginx       4.0K Apr  7  2020 data
-rw-r--r--    1 nginx    nginx        156 Feb 25 10:23 index.html
-rw-r--r--    1 nginx    nginx       2.9K Feb 25 10:24 index.php
drwxr-xr-x    6 nginx    nginx       4.0K Feb 25 10:23 lib
-rwxr-xr-x    1 nginx    nginx        283 Feb 25 10:24 occ
drwxr-xr-x    2 nginx    nginx       4.0K Feb 25 10:23 ocm-provider
drwxr-xr-x    2 nginx    nginx       4.0K Feb 25 10:24 ocs
drwxr-xr-x    2 nginx    nginx       4.0K Feb 25 10:23 ocs-provider
-rw-r--r--    1 nginx    nginx       3.0K Feb 25 10:24 public.php
-rw-r--r--    1 nginx    nginx       5.2K Feb 25 10:24 remote.php
drwxr-xr-x    4 nginx    nginx       4.0K Feb 25 10:23 resources
-rw-r--r--    1 nginx    nginx         26 Feb 25 10:23 robots.txt
-rw-r--r--    1 nginx    nginx       2.3K Feb 25 10:24 status.php
drwxr-xr-x    3 nginx    nginx       4.0K Feb 25 10:23 themes
drwxr-xr-x    2 nginx    nginx       4.0K Mar 11  2020 updater
-rw-r--r--    1 nginx    nginx        382 Feb 25 10:23 version.php

note: ll is a shortcut for ls -la
Here is my cronjob (from user nginx):
*/5 * * * * php -f /var/www/nextcloud/cron.php

The NC runs for weeks with this config, I don’t know why this happen now.

When I run sudo -u nginx php -f /var/www/nextcloud/cron.php then all is fine, no message in the NC.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. wait till the cronjob run throught

The output of your Nextcloud log in Admin > Logging:


and so on, I was going to work on it, then I noticed this error.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '...',
  'passwordsalt' => '...',
  'secret' => '...',
  'trusted_domains' => 
  array (
    0 => '...',
    1 => '...',
    2 => '...',
  ),
  'datadirectory' => '/mnt/data',
  'dbtype' => 'mysql',
  'version' => '20.0.8.1',
  'overwrite.cli.url' => '...',
  'overwriteprotocol' => 'https',
  'dbname' => '...',
  'dbhost' => '...',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '...',
  'dbpassword' => '...',
  'installed' => true,
  'trashbin_retention_obligation' => 'auto, 14',
  'versions_retention_obligation' => 'auto, 30',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'trusted_proxies' => 
  array (
    0 => '...',
    1 => '...',
  ),
  mailsettings follow...
);

The output of your Apache/nginx/system log in /var/log/____:
Nothing newer here:

2021/02/17 21:30:10 [warn] 30064#30064: *91422 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/5/00/0000000005 while reading upstream, client: 192.168.230.8, server: ..., request: "GET /remote.php/webdav/DesktopSync/KeePass/safe.kdbx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "..."
2021/02/20 01:46:39 [warn] 30064#30064: *132700 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/6/00/0000000006 while reading upstream, client: 192.168.230.8, server: ..., request: "GET /remote.php/webdav/DesktopSync/KeePass/safe.kdbx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "..."
2021/02/23 07:13:56 [warn] 30064#30064: *171264 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/7/00/0000000007 while reading upstream, client: 192.168.230.8, server: ..., request: "GET /remote.php/webdav/DesktopSync/F%C3%BChrungszeugnis.pdf?downloadStartSecret=mv6bnfw953 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "..."

Okay, the problem is back again.
Anybody any idea?

Maybe try chmod 770 -R /mnt/data/?