diff --git a/32/apache/cron.sh b/32/apache/cron.sh index b4cd9af65..b44a543c7 100755 --- a/32/apache/cron.sh +++ b/32/apache/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/32/fpm-alpine/cron.sh b/32/fpm-alpine/cron.sh index b4cd9af65..b44a543c7 100755 --- a/32/fpm-alpine/cron.sh +++ b/32/fpm-alpine/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/32/fpm/cron.sh b/32/fpm/cron.sh index b4cd9af65..b44a543c7 100755 --- a/32/fpm/cron.sh +++ b/32/fpm/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/33/apache/cron.sh b/33/apache/cron.sh index b4cd9af65..b44a543c7 100755 --- a/33/apache/cron.sh +++ b/33/apache/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/33/fpm-alpine/cron.sh b/33/fpm-alpine/cron.sh index b4cd9af65..b44a543c7 100755 --- a/33/fpm-alpine/cron.sh +++ b/33/fpm-alpine/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/33/fpm/cron.sh b/33/fpm/cron.sh index b4cd9af65..b44a543c7 100755 --- a/33/fpm/cron.sh +++ b/33/fpm/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/34/apache/cron.sh b/34/apache/cron.sh index b4cd9af65..b44a543c7 100755 --- a/34/apache/cron.sh +++ b/34/apache/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/34/fpm-alpine/cron.sh b/34/fpm-alpine/cron.sh index b4cd9af65..b44a543c7 100755 --- a/34/fpm-alpine/cron.sh +++ b/34/fpm-alpine/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/34/fpm/cron.sh b/34/fpm/cron.sh index b4cd9af65..b44a543c7 100755 --- a/34/fpm/cron.sh +++ b/34/fpm/cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs" diff --git a/README.md b/README.md index f3fedb5d3..b6bfb7f45 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ A safe home for all your data. Access & share your files, calendars, contacts, m - [Custom Data directory (`datadirectory`)](#custom-data-directory-datadirectory) - [Trusted domains (`trusted_domains`)](#trusted-domains-trusted_domains) - [Image specific](#image-specific) + - [Background jobs (`cron.php`)](#background-jobs-cronphp) - [Redis Memory Caching](#redis-memory-caching) - [E-mail (SMTP) Configuration](#e-mail-smtp-configuration) - [Object Storage (Primary Storage)](#object-storage-primary-storage) @@ -281,6 +282,18 @@ You might want to make sure the htaccess is up to date after each container upda - `NEXTCLOUD_INIT_HTACCESS` (not set by default) Set it to true to enable run `occ maintenance:update:htaccess` after container initialization. +### Background jobs (`cron.php`) + +The images ship a `/cron.sh` entrypoint that runs `php -f /var/www/html/cron.php` every 5 minutes via busybox `crond`. To run the background jobs less often, override the schedule with a standard five-field cron expression: + +- `NEXTCLOUD_CRON_SCHEDULE` (default: `*/5 * * * *`) Cron expression for `cron.php`. + +```console +$ docker run -d --volumes-from app -e NEXTCLOUD_CRON_SCHEDULE='*/30 * * * *' --entrypoint /cron.sh nextcloud +``` + +Note that Nextcloud's admin overview reports a warning once the last background job ran more than an hour ago, and jobs such as calendar event reminders are delayed by up to one interval. `TZ` applies to the schedule, so it is evaluated in the container's local time. + ### Redis Memory Caching To use Redis for memory caching as well as PHP session storage, specify the following values and also add a [Redis](https://hub.docker.com/_/redis/) container to your stack. See the [examples](https://github.com/nextcloud/docker/tree/master/.examples) for further instructions. diff --git a/docker-cron.sh b/docker-cron.sh index b4cd9af65..b44a543c7 100755 --- a/docker-cron.sh +++ b/docker-cron.sh @@ -1,4 +1,12 @@ #!/bin/sh set -eu -exec busybox crond -f -L /dev/stdout +crontabs=/var/spool/cron/crontabs + +if [ -n "${NEXTCLOUD_CRON_SCHEDULE:-}" ]; then + crontabs="${TMPDIR:-/tmp}/nextcloud-crontabs" + mkdir -p "$crontabs" + echo "$NEXTCLOUD_CRON_SCHEDULE php -f /var/www/html/cron.php" > "$crontabs/www-data" +fi + +exec busybox crond -f -L /dev/stdout -c "$crontabs"