Hello, I have a fairly basic question I think: I am confused about the cron setup. Using Owncloud 10.6.0 docker/server container on docker. Admin page says that cron is running but I am unsure how to add extra background tasks like “sudo -u www-data php occ files:scan --all” for external storage refresh.
If I look in the container I see no crontab or whatever?
In config.php I added ‘trashbin_retention_obligation’ => ‘auto, 30’,
‘versions_retention_obligation’ => ‘10, auto’,
but unsure whether these now run?
So 2 questions:
is it necessary to add something like “*/15 * * * * /usr/local/bin/docker exec -u www-data owncloud /bin/bash -c ‘/usr/bin/occ system:cron’” to my docker host cron, or is there a cron running by default in the owncloud container?
where can I add extra cron jobs or would they need to be added to host cron like above with a bash command?
Yeah, but which one? If crontab -l -u www-data returns nothing, maybe you’re using some webcron service? Replace www-data by the user running you webserver.
BTW, I’m not sure, whether or not your sudo -u www-data php occ files:scan --all is affecting external volumes at all.
If it is an container thing I can try to find it.
It would help though, if someone could explain the design concept, so I would know what to look for: so is it indeed that a sort of cron proces already runs, OR is it necessary to frequently kick off occ system:cron in the host cron?
And does this system:cron only look at possible jobs in the config.php and would additionals need to go to the host cron again?
docker-compose exec owncloud entrypoint bash # how to get a shell if you're using docker-compose and the owncloud container is defined with the name owncloud
root@f394a36d0a95: /var/www/owncloud # cat /etc/cron.d/owncloud
*/1 * * * * www-data /usr/bin/cronjob
root@f394a36d0a95: /var/www/owncloud # cat /usr/bin/cronjob
#!/usr/bin/env bash
set -eo pipefail
[[ "${DEBUG}" == "true" ]] && set -x
if [[ -d "${OWNCLOUD_PRE_CRONJOB_PATH}" ]]
then
for FILE in $(find ${OWNCLOUD_PRE_CRONJOB_PATH} -iname \*.sh | sort)
do
source ${FILE}
done
fi
if dpkg --compare-versions $(occ config:system:get version | tail -1) "ge" "10.3"
then
occ system:cron
else
if [[ "$(id -u)" == "0" ]]
then
su-exec www-data php -f /var/www/owncloud/cron.php
else
php -f /var/www/owncloud/cron.php
fi
fi
if [[ -d "${OWNCLOUD_POST_CRONJOB_PATH}" ]]
then
for FILE in $(find ${OWNCLOUD_POST_CRONJOB_PATH} -iname \*.sh | sort)
do
source ${FILE}
done
fi
Search for cron on this page for additional variables to adjust cron execution:
Finally I would recommend to install your cron job independently of anything ownCloud has created, as that might be overwritten with a container upgrade.
Thanks, these I indeed had found, but not sure whether it indeed was running and what and how it triggered.
I will try the environment settings and will add some stuff to see if I can find out what is going on. Pretty sure i can work from here on: thanks a lot!.
Ok, indeed this cron shows to run. Now I need to figure out what jobs are part of the owncloud snippets every minutes system:cron call and which not…
To keep the possible custom cron entries I will mount a cron snippet outside the container to the container’s /etc/cron.d. That should work sufficiently well. (ie -v some-host-folder/snippet:/etc/cron.d/snippet)
Would have expected to have cleaned up my versions of yesterday though, as I set that to 1 day old with 1 day max. will wait another day to see if that will still happen…
Edit: happened a bit later. Probably timezone thingy…