[NC20 running with docker-compose] Cron container is not working

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 18.0.2): 20.0.1 (docker-compose)
Operating system and version (eg, Ubuntu 20.04): Debian GNU/Linux 10 (buster)
Apache or nginx version (eg, Apache 2.4.25): nginx/1.14.2
PHP version (eg, 7.1): 7.4.12

The issue you are facing:
I tried to change the background tasks setting to use Cron. For this, I created another docker container in which the

Here is a snippet of my docker-compose.yml:

  nextcloud:
    image: nextcloud
    container_name: nextcloud
    networks:
      - nextcloud
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ${NEXTCLOUD_ROOT}/html:/var/www/html
      - ${NEXTCLOUD_ROOT}/data:/opt/nextcloud/data
    extra_hosts:
      - "${NEXTCLOUD_FQDN}:${NEXTCLOUD_IPADDRESS}"
      - "${COLLABORA_FQDN}:${NEXTCLOUD_IPADDRESS}"
    depends_on:
      - mariadb
      - redis
    environment:
      - NEXTCLOUD_TRUSTED_DOMAINS='${NEXTCLOUD_FQDN}'
      - NEXTCLOUD_DATA_DIR=/opt/nextcloud/data
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_HOST=${MYSQL_HOST}
      - REDIS_HOST=${REDIS_HOST}
      - REDIS_HOST_PASSWORD=${REDIS_PASSWORD}
    restart: unless-stopped

  cron:
    image: nextcloud
    restart: always
    volumes:
      - ${NEXTCLOUD_ROOT}/html:/var/www/html
      - ${NEXTCLOUD_ROOT}/data:/opt/nextcloud/data
    entrypoint: /cron.sh
    depends_on:
      - mariadb
      - redis
    networks:
      - nextcloud

Log output for this cron container:

cron_1       | 2020-11-09T19:00:00.756923492Z crond: crond (busybox 1.30.1) started, log level 0
cron_1       | 2020-11-09T19:00:00.756948589Z crond: user:www-data entry:(null)
cron_1       | 2020-11-09T19:00:00.756950963Z 100001000010000100001000010000100001000010000100001000010000
cron_1       | 2020-11-09T19:00:00.756952927Z 111111111111111111111111
cron_1       | 2020-11-09T19:00:00.756954630Z 11111111111111111111111111111111
cron_1       | 2020-11-09T19:00:00.756957756Z 111111111111
cron_1       | 2020-11-09T19:00:00.756959369Z 1111111
cron_1       | 2020-11-09T19:01:00.757199354Z crond: user:www-data entry:(null)
cron_1       | 2020-11-09T19:01:00.757228800Z 100001000010000100001000010000100001000010000100001000010000
cron_1       | 2020-11-09T19:01:00.757231234Z 111111111111111111111111
cron_1       | 2020-11-09T19:01:00.757233088Z 11111111111111111111111111111111
cron_1       | 2020-11-09T19:01:00.757234891Z 111111111111
cron_1       | 2020-11-09T19:01:00.757237045Z 1111111
cron_1       | 2020-11-09T19:01:00.757238799Z crond: wakeup dt=60
cron_1       | 2020-11-09T19:01:00.757240562Z crond: file www-data:
cron_1       | 2020-11-09T19:01:00.757242355Z crond:  line php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:02:00.757306747Z crond: wakeup dt=60
cron_1       | 2020-11-09T19:02:00.757325472Z crond: file www-data:
cron_1       | 2020-11-09T19:02:00.757327796Z crond:  line php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:03:00.757446224Z crond: wakeup dt=60
cron_1       | 2020-11-09T19:03:00.757473535Z crond: file www-data:
cron_1       | 2020-11-09T19:03:00.757475859Z crond:  line php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:04:00.757618548Z crond: wakeup dt=60
cron_1       | 2020-11-09T19:04:00.757647873Z crond: file www-data:
cron_1       | 2020-11-09T19:04:00.757650949Z crond:  line php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:05:00.757767467Z crond: wakeup dt=60
cron_1       | 2020-11-09T19:05:00.757798646Z crond: file www-data:
cron_1       | 2020-11-09T19:05:00.757801531Z crond:  line php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:05:00.757803715Z crond:  job: 0 php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:05:00.757903222Z crond: child running /bin/bash
cron_1       | 2020-11-09T19:05:00.757992670Z crond: USER www-data pid   6 cmd php -f /var/www/html/cron.php
cron_1       | 2020-11-09T19:05:00.772297251Z Could not open input file: /var/www/html/cron.php

Do you have any idea what’s going on here?
Executing docker exec -it -u www-data nextcloud php -f /var/www/html/cron.php manually is working fine…

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

The output of your Nextcloud log in Admin > Logging:

nothing related to background tasks / cron

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,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'nextcloud-redis',
    'password' => 'xxx',
    'port' => 6379,
  ),
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' =>
  array (
    0 => 'xxx',
  ),
  'datadirectory' => '/opt/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '20.0.1.1',
  'overwrite.cli.url' => 'xxx',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'xxx',
  'mail_domain' => 'xxx',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => 'xxx',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' =>
  array (
    0 => 'admin',
  ),
  'twofactor_enforced_excluded_groups' =>
  array (
  ),
  'trusted_proxies' =>
  array (
    1 => '127.0.0.1',
  ),
  'overwriteprotocol' => 'https',
  'overwritehost' => 'xxx',
  'loglevel' => 2,
  'maintenance' => false,
);

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

nothing related to background tasks / cron

Well, after stopping + removing the related docker containers and checking directory / file permissions again, it’s now working fine.

Could be closed.

Same problem on a Windows WSL2 setup.
What should I do?