Failure Switching to Cron from AJAX - NC v23.0.0 - Portainer & Docker - Background Processes - MariaDB

[/details]

Nextcloud version (eg, 20.0.5): 23.0.0
Operating system and version (eg, Ubuntu 20.04): OMV5; Debian 10 Buster
Apache or nginx version (eg, Apache 2.4.25): Apache
PHP version (eg, 7.4): 8.0.14
MariaDB Version (Portainer): 1:10.6.5+maria~focal

The issue you are facing:

Switching from AJAX to Cron Background Jobs will not work using Portainer v2.11.0. I did a lot of effort by myself then with a friend who also self-hosts NextCloud. What I first did was refer to the Background Jobs documentation, and followed the instructions under the Cron bolded heading:

crontab -u www-data -e → pasted this “/5 * * * * php -f /var/www/nextcloud/cron.php" → crontab -u www-data -l → returned this "/5 * * * * php -f /var/www/nextcloud/cron.php”.

According to this YouTube video (https://www.youtube.com/watch?v=8dzJGM22E88) the user did the above modifications and when they travelled to the settings menu, the Background Jobs was switched from AJAX to Cron as expected. I have a friend who self-hosts NC, and he confirmed that he followed the same steps of the video and “it works on my machine,” which is annoying to hear at this point since I’ve rebuilt the Portainer stack (MariaDB+NextCloudv23) with different versions of NextCloud and MariaDB but kept having the same issues.

I also read from past posts ([NC20 running with docker-compose] Cron container is not working) on this forum that users were incorporating a Cron container within their deployment of NextCloud, I tried using these Docker-Compose files and experienced failures. Also the solution from the past post was the user restarted NextCloud. The NextCloud Docker-Compose file I’m using is this template from DBTech, passwords are fake:

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed

    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=Bund7zXeVz7YnFknLGcnUjHtk #change this
      - MYSQL_PASSWORD=HFdMe9rn5kf7A8Pqc8v86Pre5 #change this
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8888:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=HFdMe9rn5kf7A8Pqc8v86Pre5  #change this to match the mysql_password above
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

The code-block above is exactly what Docker-Compose I am running right now. I made some adjustments which are adding these lines to the beginning of the `.htaccess:

php_value memory_limit 10G
php_value upload_max_filesize 16G
php_value post_max_size 16G
php_value max_input_time 3600
php_value max_execution_time 3600

I’ve also done some other things that I will mention. After doing a fresh stack install of MariaDB and NextCloud using the above Docker-Compose text, I will enter into the container of NextCloud and apt update then apt upgrade then apt install apt-utils then apt-get install nano then apt-get install cron then I would do the following again, since it is a fresh installation:

crontab -u www-data -e → pasted this “/5 * * * * php -f /var/www/nextcloud/cron.php" → crontab -u www-data -l → returned this "/5 * * * * php -f /var/www/nextcloud/cron.php”.

I would then exit the terminal of the NextCloud container within the Stack (Maria+NC) and then enter into Maria to do apt update && upgrade. After, I would highlight both MariaDB and NC, then do a restart in Portainer. The local address connection to NC works fine, and the NGINX Proxy Manager which I have in Portainer has no issues forwarding the NC ports to display on my subdomain.

There was a mention that I should be using user www-data to execute the Cron process, or something loosely like that, from memory, but I have no link on hand. I entered into Portainer to edit the NextCloud container, and assigned the user under the Command and Logging heading to www-data. I did a restart and then no success.

Furthermore, I also checked the Portainer logs, which do auto-refresh. So, when I check the container, I cannot see anything jumping out at me to indicate what is going wrong with the switch to Cron. I sit beside my server since I host on my own metal and the HDD drives are writing significantly more than usual when doing these set-ups. Also, my data and config are held on my HDD for NextCloud.

An important detail, I intend to have NC host 6-7Tb of data on my old gaming machine turned into an OMV5 server. I think Cron is needed for something like this. A lot of it will be HD photos, video, memes, music, documents, Zotero syncing, etc. I want to use NC for many things, but I want to have zero error messages before I begin my migration from basic file structures into NextCloud.

Is this the first time you’ve seen this error? (Y/N): Yes, but I am also new to NextCloud, and an intermediate for self-hosting.

Steps to replicate it:

  1. Use Docker-Compose text above to create NextCloud+MariaDB stack.
  2. Enter into either container in the stack; do an update, upgrade, change .htaccess, increase PHP_memory_limit and PHP_upload_limit to 10000M each in the ‘env’ tab of the NextCloud Portainer Edit page.
  3. Make changes regarding AJAX → Cron as per NextCloud docs, and assistance of someone who made the Cron switch.
  4. Restart MariaDB and NextCloud containers (successfully)
  5. Log in to NextCloud, go to Admin settings, then go to Background Jobs settings page
  6. See “Background jobs: Last job execution ran 15 hours ago. Something seems wrong.” as an error at the top of the Background Jobs page.
  7. Scream internally.

The output of your Nextcloud log in Admin > Logging:

{"reqId":"KpdDhh9mEUc8m51RiOCH","level":3,"time":"2022-01-12T01:42:57+00:00","remoteAddr":"192.168.0.7","user":"admin","app":"index","method":"GET","url":"/apps/theming/img/core/filetypes/folder.svg?v=0","message":"Could not create folder","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"23.0.0.10","exception":{"Exception":"OCP\\Files\\NotPermittedException","Message":"Could not create folder","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/AppData/AppData.php","line":156,"function":"newFolder","class":"OC\\Files\\Node\\Folder","type":"->","args":["0"]},{"file":"/var/www/html/apps/theming/lib/ImageManager.php","line":156,"function":"newFolder","class":"OC\\Files\\AppData\\AppData","type":"->","args":["0"]},{"file":"/var/www/html/apps/theming/lib/ImageManager.php","line":171,"function":"getCacheFolder","class":"OCA\\Theming\\ImageManager","type":"->","args":[]},{"file":"/var/www/html/apps/theming/lib/Controller/IconController.php","line":90,"function":"getCachedImage","class":"OCA\\Theming\\ImageManager","type":"->","args":["icon-core-filetypes_folder.svg"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getThemedIcon","class":"OCA\\Theming\\Controller\\IconController","type":"->","args":["core","filetypes/folder.svg"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Theming\\Controller\\IconController"},"getThemedIcon"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Theming\\Controller\\IconController"},"getThemedIcon"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Theming\\Controller\\IconController","getThemedIcon",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"app":"core","image":"filetypes/folder.svg","_route":"theming.Icon.getThemedIcon"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/theming/img/core/filetypes/folder.svg"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Files/Node/Folder.php","Line":173,"CustomMessage":"--"},"id":"61df53b9ea5f6"}
{"reqId":"k8F5Ulo1zp5d9m6al92u","level":3,"time":"2022-01-12T01:42:57+00:00","remoteAddr":"192.168.0.7","user":"admin","app":"index","method":"GET","url":"/apps/theming/img/core/filetypes/image.svg?v=0","message":"Could not create folder","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"23.0.0.10","exception":{"Exception":"OCP\\Files\\NotPermittedException","Message":"Could not create folder","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Files/AppData/AppData.php","line":156,"function":"newFolder","class":"OC\\Files\\Node\\Folder","type":"->","args":["0"]},{"file":"/var/www/html/apps/theming/lib/ImageManager.php","line":156,"function":"newFolder","class":"OC\\Files\\AppData\\AppData","type":"->","args":["0"]},{"file":"/var/www/html/apps/theming/lib/ImageManager.php","line":171,"function":"getCacheFolder","class":"OCA\\Theming\\ImageManager","type":"->","args":[]},{"file":"/var/www/html/apps/theming/lib/Controller/IconController.php","line":90,"function":"getCachedImage","class":"OCA\\Theming\\ImageManager","type":"->","args":["icon-core-filetypes_image.svg"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":217,"function":"getThemedIcon","class":"OCA\\Theming\\Controller\\IconController","type":"->","args":["core","filetypes/image.svg"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":126,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Theming\\Controller\\IconController"},"getThemedIcon"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Theming\\Controller\\IconController"},"getThemedIcon"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Theming\\Controller\\IconController","getThemedIcon",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"app":"core","image":"filetypes/image.svg","_route":"theming.Icon.getThemedIcon"}]},{"file":"/var/www/html/lib/base.php","line":1006,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/theming/img/core/filetypes/image.svg"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Files/Node/Folder.php","Line":173,"CustomMessage":"--"},"id":"61df53b9ea7ac"}
{"reqId":"uXtpq6zCyrQshgZW89mD","level":2,"time":"2022-01-12T01:39:06+00:00","remoteAddr":"192.168.0.7","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"","id":"61df53b9ea7b9"}
{"reqId":"uXtpq6zCyrQshgZW89mD","level":2,"time":"2022-01-12T01:39:06+00:00","remoteAddr":"192.168.0.7","user":"--","app":"no app in context","method":"POST","url":"/index.php","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"","id":"61df54ce924af"}
{"reqId":"DgGbGBCdJ4Fx8uZOT3Xz","level":2,"time":"2022-01-12T01:38:51+00:00","remoteAddr":"192.168.0.7","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"","id":"61df54ce924b9"}
{"reqId":"DgGbGBCdJ4Fx8uZOT3Xz","level":2,"time":"2022-01-12T01:38:51+00:00","remoteAddr":"192.168.0.7","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"","id":"61df54ce924c3"}
{"reqId":"dqTsJuSmrJtrlmHdkgsV","level":2,"time":"2022-01-12T01:36:44+00:00","remoteAddr":"PUBLIC-IP","user":"--","app":"no app in context","method":"GET","url":"/index.php/204","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.18.1","version":"","id":"61df54ce924cd"}
{"reqId":"sVxkPB1yI7O2ZCUjPAKC","level":2,"time":"2022-01-12T01:27:13+00:00","remoteAddr":"192.168.0.7","user":"--","app":"no app in context","method":"GET","url":"/","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","version":"","id":"61df54ce924e1"}
{"reqId":"dkBu92KY3PfeV2RQDJkr","level":2,"time":"2022-01-12T01:21:43+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"GET","url":"/index.php/204","message":"Could not detect any host in https:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.18.1","version":"","id":"61df54ce924f5"}
{"reqId":"dkBu92KY3PfeV2RQDJkr","level":2,"time":"2022-01-12T01:21:43+00:00","remoteAddr":"PUBLIC-IP","user":"--","app":"no app in context","method":"GET","url":"/index.php/204","message":"Could not detect any host in http:///data/htaccesstest.txt","userAgent":"Mozilla/5.0 (Android) Nextcloud-android/3.18.1","version":"","id":"61df54ce924ff"}

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'ocme0ophid9u',
  'passwordsalt' => 'password',
  'secret' => '/password',
  'trusted_domains' => 
  array (
    0 => '192.168.0.2:8888
    1 => 'subdomain.domain.com',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '23.0.0.10',
  'overwrite.cli.url' => 'http://192.168.0.2:8888',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'password',
  'installed' => true,
);

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

I `cd` into /var/log of my nextcloud container and there was nothing I could find that I could paste in here.

It’s getting pretty late local time as I’m finishing this post. I have other chores to be done aside from server work. I will hopefully be replying tomorrow morning. Thank you in advance for all the help.