I’m running an environment with Nextcloud, mariadb, redis running as Docker containers. As it is still test, there is no https enabled yet. I’m trying to use the hosts’s cron and everything else is fine so far except the message "Last job execution ran a day ago. Something seems wrong. ". It still appears even I seem to have everything configured as described here.
If I run docker exec -u www-data nextcloud php /var/www/html/cron.php manually it’s working. Searching the forum posts didn’t bring success so far. I don’t exactly know how to analyze cron logs.
Any ideas would be very much appreciated.
Please post the exact cron entry you added and which user you added the entry under.
Also, are you using Docker Compose at all for your NC stack or solely running all the containers manually?
If your cron job is failing it’ll probably try to email the user. That’ll show up in /var/mail/USERNAME (I’m taking a wild guess here since you didn’t provide any details about your host environment).
P.S. You can fully container cron (so that you don’t have to touch your host config to add cron entries) by adding a cron container to your Docker Compose (if you use Compose) - e.g.
cron:
depends_on:
- db
- redis
- app
image: nextcloud:27-apache
restart: unless-stopped
volumes:
- app-var-www-html:/var/www/html
entrypoint: /cron.sh
networks:
- app-network
Just make sure it has all the same volumes as your app (NC) container.
Hi, thanks for your reply.
I’m running the NC Stack on Ubuntu 20.04.6 LTS,
docker-compose for starting NC and mariadb. Redis is currently called separately also via docker-compose.
The cron entry looks as follows:
sudo crontab -l -u www-data
*/5 * * * * docker exec -u www-data nextcloud php /var/www/html/cron.php
Mail isn’t enabled on my system, so I have no entries under /var/mail
In the next days I’ll give your suggestion a try and dockerize cron as well.
Please let me know if there is more detailed information required.
Meanwhile I got both variants running.
While using the hosts cron, it was missing the full path of the docker and php commands. Now the cron entry is as follows:
*/5 * * * * /snap/bin/docker exec -u www-data nextcloud /usr/local/bin/php -f /var/www/html/cron.php
I also got cron containerized running in the way you provided above. The nextcloud docker image (in my case 27.0.1) already got an entry for www-data under
/var/spool/cron/crontabs
Thanks again for your help!