Hello,
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:
---
services:
nextcloud:
image: nextcloud
container_name: nextcloud
restart: unless-stopped
network_mode: nextcloud-net
ports:
- 80:80
external_links:
- mariadb:mariadb
volumes:
- ~/Users/docker/nextcloud/nextcloud:/var/www/html
- ~/Users/docker/nextcloud/config:/var/www/html/config
- /Volumes/Files/nextcloud:/var/www/html/data
environment:
- TZ=America/New_York
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_HOST
- REDIS_HOST
- REDIS_HOST_PORT
- REDIS_HOST_PASSWORD
- NEXTCLOUD_ADMIN_USER
- NEXTCLOUD_ADMIN_PASSWORD
- NEXTCLOUD_TRUSTED_DOMAINS
- PHP_MEMORY_LIMIT
- PHP_UPLOAD_LIMIT
- APACHE_BODY_LIMIT
depends_on:
- nextcloud-redis
cron:
image: nextcloud
container_name: nextcloud-cron
volumes:
- ~/Users/docker/nextcloud/nextcloud:/var/www/html
- ~/Users/docker/nextcloud/config:/var/www/html/config
- /Volumes/Files/nextcloud:/var/www/html/data
entrypoint: /cron.sh
restart: unless-stopped
network_mode: nextcloud-net
nextcloud-redis:
image: redis:alpine
container_name: nextcloud-redis
hostname: nextcloud-redis
volumes:
- ~/Users/docker/redis:/data
ports:
- 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!