Owncloud 10.6.0 docker cron

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?

Regards

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.

1 Like

Hi alfredb,
ps -ef inside the container gives me:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 17:11 ? 00:00:00 /bin/sh /usr/sbin/apachectl -f /etc/apache2/apache2.conf -DFOREGROUND
root 188 1 0 17:11 ? 00:00:00 /usr/sbin/cron -l
root 193 1 0 17:11 ? 00:00:01 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 194 193 0 17:11 ? 00:00:06 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 195 193 0 17:11 ? 00:00:04 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 196 193 0 17:11 ? 00:00:04 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 197 193 0 17:11 ? 00:00:04 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 198 193 0 17:11 ? 00:00:04 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
www-data 308 193 0 17:13 ? 00:00:04 /usr/sbin/apache2 -f /etc/apache2/apache2.conf -DFOREGROUND
root 19531 0 0 22:59 pts/0 00:00:00 bash
root 19549 19531 0 22:59 pts/0 00:00:00 ps -ef

In the admin page, the system cron (last one) is selected.
image
Both crontab -l for www-data or root say no crontab for…

Regards

Thanks for the info.

This is maybe a container thing, where I cannot help. Sorry.

1 Like

No worries, thanks for trying.

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?

The info I find on it is not clear on this to me.

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.

1 Like

Hello eneubauer,

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!.

Regards

2 Likes

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)

2 Likes

Ok, see now the cron in the log. Only show with log_level => 0 it seems. Also see:
www-data@owncloud: /var/www/owncloud # php occ background:queue:status
±-------±------------------------------------------------------±--------------------------±-----------------------------+
| Job ID | Job | Last Run | Job Arguments |
±-------±------------------------------------------------------±--------------------------±-----------------------------+
| 1 | OCA\Files\BackgroundJob\ScanFiles | 2021-03-16T12:39:02+01:00 | |
| 2 | OCA\Files\BackgroundJob\DeleteOrphanedItems | 2021-03-16T12:36:03+01:00 | |
| 3 | OCA\Files\BackgroundJob\CleanupFileLocks | 2021-03-16T12:41:02+01:00 | |
| 4 | OCA\Files\BackgroundJob\CleanupPersistentFileLocks | 2021-03-16T12:37:02+01:00 | |
| 5 | OCA\DAV\CardDAV\SyncJob | 2021-03-15T20:51:03+01:00 | |
| 6 | OCA\DAV\BackgroundJob\CleanProperties | 2021-03-15T20:52:03+01:00 | |
| 7 | OCA\Activity\BackgroundJob\EmailNotification | 2021-03-16T12:32:03+01:00 | |
| 8 | OCA\Activity\BackgroundJob\ExpireActivities | 2021-03-15T20:52:03+01:00 | |
| 9 | OCA\Federation\SyncJob | 2021-03-15T20:52:03+01:00 | |
| 10 | OCA\Files_Sharing\DeleteOrphanedSharesJob | 2021-03-16T12:39:02+01:00 | |
| 11 | OCA\Files_Sharing\ExpireSharesJob | 2021-03-15T20:52:03+01:00 | |
| 12 | OCA\Files_Sharing\External\ScanExternalSharesJob | 2021-03-16T12:41:02+01:00 | |
| 13 | OCA\Files_Trashbin\BackgroundJob\ExpireTrash | 2021-03-16T12:34:02+01:00 | |
| 14 | OCA\Files_Versions\BackgroundJob\ExpireVersions | 2021-03-16T12:16:02+01:00 | |
| 15 | OCA\Market\CheckUpdateBackgroundJob | 2021-03-15T20:52:03+01:00 | |
| 16 | OCA\UpdateNotification\Notification\BackgroundJob | 2021-03-15T20:52:05+01:00 | |
| 17 | OC\Authentication\Token\DefaultTokenCleanupJob | 2021-03-16T12:41:02+01:00 | |
| 18 | OCA\OAuth2\BackgroundJob\CleanUp | 2021-03-15T21:00:04+01:00 | |
| 19 | OCA\BruteForceProtection\Jobs\ExpireOldAttempts | 2021-03-15T20:59:04+01:00 | |
| 20 | OCA\PasswordPolicy\Jobs\PasswordExpirationNotifierJob | 2021-03-16T09:03:05+01:00 | |
| 23 | OC\Log\Rotate | 2021-03-16T12:41:03+01:00 | /mnt/data/files/owncloud.log |
±-------±------------------------------------------------------±--------------------------±-----------------------------+

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…

BTW The snippet mount will only work if it owned by root at start it seems… So have to think of something else (docker exec in host cron I guess).

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.