Allow custom cron jobs
I'm looking for a way to make occ preview:generate-all run periodically in a Docker setup.
Maybe adding a line like this to /var/spool/cron/crontabs/www-data would be a good way to enable using custom cron jobs?
*/5 * * * * if [ -f /var/www/html/cron_custom.sh ]; then bash /var/www/html/cron_custom.sh; fi
I was looking to execute a periodic job for this exact purpose too. I was hoping for something in the README to teach us how to use the supervisord they embed in the cron Dockerfile example, but I don't understand how to use it.
The next closest thing would be to add in the host a cron job running something like
docker exec --user www-data CONTAINER_ID php occ preview:generate-all
I had no idea there's supervisord in there. It can be turned into a poor man's cron with a trick but it's very inflexible when used this way. It can be ran every minute or every hour.
But I think using cron for cron jobs would be better.
I was facing the same issue. For now, I'm using this workaround to run occ preview:generate-all every 15 mins:
The user is member of the docker group: sudo usermod -a -G docker USERNAME
-
User crontag,
crontab -e:*/15 * * * * $HOME/pre-gen.sh > /dev/null 2>&1 -
$HOME/pre-gen.sh#!/usr/bin/env bash echo "--- $(date --utc +%FT%TZ) ----------------------------------------" >>$HOME/pre-generate.log 2>&1 docker exec -i --user 33 nextcloud-app-1 ./occ preview:pre-generate -v >>$HOME/pre-generate.log 2>&1
I'm doing the same but it's a hack.
https://github.com/nextcloud/docker/issues/361
@jjasoncool yeah, building your own Dockerfile or running cronjobs on the host, not really solutions to the problem.
You can ref this, build this is running normally. https://github.com/nextcloud/docker/issues/1695#issuecomment-1383615123
Duplicate of #820