Nextcloud Docker setup - Help needed with cron


I am new to nextcloud and I have been setting up the official nextcloud container in docker with an external MariaDB running in a different container, as well as REDIS and a second nextcloud container for CRON like I have seen in many examples. Everything is running fine including corn (according to my admin dashboard in Nextcloud)

There is however one thing I do not fully understand, where and how do I add cron jobs in this configuration?

I need to add some cron jobs for example for the previewgenerator app I would need to add a cron job that runs regularly and updates previews but am at a loss on how to do it in this configuration.

My initial thought was that I would get into the console of the nextcloud-cron container and set it up there by running something lik sudo crontab -u www-data -e but that doesn’t work. I am already root in the container and it doesn’t recognize the crontab command. There are folders for /etc/cron.d and /etc/cron.daily.

So how would add occ preview:pre-generate to a cronjob that runs at least ever 24hours or so?

Please see my docker compose file:

    image: nextcloud
    container_name: nextcloud
    restart: unless-stopped
    network_mode: nextcloud-net
      - 80:80
      - mariadb:mariadb
      - ~/Users/docker/nextcloud/nextcloud:/var/www/html
      - ~/Users/docker/nextcloud/config:/var/www/html/config
      - /Volumes/Files/nextcloud:/var/www/html/data
      - TZ=America/New_York
      - MYSQL_USER
      - MYSQL_HOST
      - REDIS_HOST
      - nextcloud-redis

    image: nextcloud
    container_name: nextcloud-cron
      - ~/Users/docker/nextcloud/nextcloud:/var/www/html
      - ~/Users/docker/nextcloud/config:/var/www/html/config
      - /Volumes/Files/nextcloud:/var/www/html/data
    entrypoint: /
    restart: unless-stopped
    network_mode: nextcloud-net
   image: redis:alpine
   container_name: nextcloud-redis
   hostname: nextcloud-redis
      - ~/Users/docker/redis:/data
      - 6379:6379
   restart: unless-stopped
   command: redis-server --requirepass "REDIS-Password"
   network_mode: nextcloud-net

Let me know if you need anything other info in order to help!

Thank you so much!

this are not “cron” jobs in terms of admin doing some task it’s more “internal” stuff - installed apps could register jobs which will run automatically (background jobs)… and there is usually no need to do something manual - AFAIK preview generator scans the system on it’s own doesn’t need additional cron jobs. I you need to run some admin task you can use your OS scheduler/cron jobs to start you admin tasks.

Ok, that does make sense but then I have to ask what is the nextcloud-cron container for?

As for preview generator:

Is that the case though?

This says to create a cron job:

After reading it again says system cronjob, since I run it in portainer on a server what would that mean?

I thought that’s what the cron container is for but guess I am wrong.

Sorry but I am getting pretty confused at the moment.

to run background jobs.

you must create another container running cron.

So another one besides the nextcloud-cron container I already have?
Sorry but really having trouble wrapping my head around this one.
I thought that is exactly the one and that it is there where I would add cron jobs if I had to add any manually.

use your OS scheduler to run your custom jobs. Cron container is for NC internal jobs.

Docker .examples

Ok, that makes sense then. Thank you!