Docker setup & cron

Hey guys,

as far as i can tell the crontab entry is done here. So as you can see, inside the container the file /var/spool/cron/crontabs/www-data is used and it usually contains one line like */5 * * * * php -f /var/www/html/cron.php for executing the cron.php every 5 minutes. If you want to do any additional cron tasks you could mount a custom crontab file and add any desired lines. A snippet of the corresponding docker-compose file could look like this:

cron:
    image: nextcloud:apache
    restart: always
    volumes:
      - nextcloud:/var/www/html
      - ./mycronfile:/var/spool/cron/crontabs/www-data
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

while the content of mycronfile could be something like

*/5 * * * * php -f /var/www/html/cron.php
0   0 * * 0 php -f /var/www/html/occ fulltextsearch:index

which will additionally index your NC instance once a week on sunday night at 0:00.

1 Like