Nextcloud on docker: cron.php configuration

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5):
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04 / docker
Apache or nginx version (eg, Apache 2.4.25): nginx
PHP version (eg, 7.4): replace me

The issue you are facing:
Get a warning in the admin panel that the cron job was not executed for several hours.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. I use the cron job. Did as mentioned in the docu. Did
    sudo crontab -u www-data -e
    the set
    */5 * * * * php -f /docker/volumes/ncdata/_data/nextcloud/cron.php

  2. However, it seems not to be executed. Therefore I tried manually. There is no output, but it seems to work as I do not see the message anymore:

www-data@69bd64536130:~/html$ ls
3rdparty  COPYING  config       core      custom_apps  dist        index.php  nextcloud-init-sync.lock  ocm-provider  ocs-provider  remote.php  robots.txt  themes
AUTHORS   apps     console.php  cron.php  data         index.html  lib        occ                       ocs           public.php    resources   status.php  version.php
www-data@69bd64536130:~/html$ php cron.php
www-data@69bd64536130:~/html$ php -f cron.php

The output of your Nextcloud log in Admin > Logging:

not relevant

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

not relevant

The output of your Apache/nginx/system log in /var/log/____:

not relevant

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

not relevant

You can rebuild the docker image with cron support which is fairly easy to do (they provide a Dockerfile for it). But a simpler solution is to call cron.php from the host using docker exec. The difference between this and what you did above is it executes cron.php inside the container.

I don’t have it in front of me at the moment but it’s something similar to

*/5 * * * * docker exec -u www-data php -f /var/www/html/cron.php

1 Like

Many thanks. It works with:

docker exec -u www-data nextcloud php -f /var/www/html/cron.php

nextcloud is my container name, you have to adapt it probably