Crontab error: "Cron issue. Last job execution ran 3 hours ago. Something seems wrong"

Recently i tried change my nextcloud to Cron job, but in the web interface i receive the erros mensage: “Cron issue. Last job execution ran 3 hours ago. Something seems wrong”

The step by step I did was: go to the web interface and select Cron, after that I configured the cron tab to run this process every 5 minutes. Even with these settings the error continues to appear. So I ran the command sudo -u www-data php /Nextcloud/app/cron.php and some errors were returned, perhaps they are the root of the problem.

Command return: sudo crontab -e -u www-data

Errors returned from sudo -u www-data php /Nextcloud/app/cron.php command:

Nextcloud version: 29.0.3
PHP version: 8.2.20
SO: Debian with OpenMediaVault aplication

Please post your Compose file.

We need to know precisely which image you’re running too.

In general though, it appears you’re trying to run cron on your underlying host rather than within the app container (which is unlikely to be what you want).

ok, thanks for your answer,

config.php:

<?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,
    ),
  ),
  'upgrade.disable-web' => true,
  'instanceid' => 'ocoe44xc5oux',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxxx',
  'trusted_domains' =>
  array (
    0 => '192.xxxx',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '29.0.3.4',
  'overwrite.cli.url' => 'http://192.xxxx',
  'dbname' => 'xxxx',
  'dbhost' => 'xxxx',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xxxx',
  'dbpassword' => 'xxxx',
  'installed' => true,
  'maintenance_window_start' => 1,
);

Compose file:

services:
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxxx
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx

  app:
    image: nextcloud:latest
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/app:/var/www/html
    environment:
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
      - MYSQL_HOST=db

Hope this helps, any contributions are welcome!

The easiest/cleanest way to run cron in your situation is like this:

Adjust the volumes (and image) to exactly match your app container.

2 Likes

Do you suggest implementing the cron configuration directly through compose? Without the need to manually configure crontab from within my operating system? Until now I thought the only way to configure this was the way I was doing it…

This may be a silly question, I’m new to this, I just want to be sure hahaha

Correct. :slight_smile:

I added the cron configuration to compose but the error message in the web interface still persists. Maybe I should do some more configuration?

In volumes i seted /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/app:/var/www/html, maybe i should set /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56 b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/db:/var/lib/mysql ?

Compose File:

services:
  cron:
    image: nextcloud:latest
    restart: always
    volumes:
      - /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/app:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db
      - app
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxxx
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx

  app:
    image: nextcloud:latest
    restart: always
    ports:
      - 8080:80
    links:
      - db
    volumes:
      - /srv/dev-disk-by-uuid-22480d1e-336a-4a6e-8a56-b5f3ccb4ba69/ServerTest/Aplications/Nextcloud/app:/var/www/html
    environment:
      - MYSQL_PASSWORD=xxxx
      - MYSQL_DATABASE=xxxx
      - MYSQL_USER=xxxx
      - MYSQL_HOST=xxxx

Containers:

Cron persist error:

No. That other volume is your db volume. Don’t attach it to your cron container.

Check the Docker log for your new cron container (i.e. docker compose logs cron).

Ok, returned this:

It doesn’t seem to be a problem with the cron container, right?

Don’t know. Of course, my nextcloud is installed differently. But I had a problem with just this. Is this going to help you? I just have nextcloud installed via apache2 and php8.2

As incredible as it may seem, it now started working, out of nowhere…

After doing the cron configuration in compose and verifying that, apparently, it had not worked, I left nextcloud aside and went to sleep. Now in the morning when I woke up everything seems to work perfectly.

Thank you for your help!!!

2 Likes