Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

system cron #49

Closed
mathroc opened this issue Feb 14, 2016 · 11 comments
Closed

system cron #49

mathroc opened this issue Feb 14, 2016 · 11 comments
Labels

Comments

@mathroc
Copy link

mathroc commented Feb 14, 2016

to have owncloud use system cron when using docker images, it would be nice to have cron running too in the container and already configured according to https://doc.owncloud.org/server/8.2/admin_manual/configuration_server/background_jobs_configuration.html

@lazyfrosch
Copy link
Contributor

On my setup I use a systemd timer for that. You could also use docker exec for it:

owncloud-cron.service

[Unit]
Description=Lazyfrosch.de Owncloud Cronjob
BindsTo=docker.service
BindsTo=mariadb.service
Requires=docker.service
Requires=mariadb.service

[Service]
Type=oneshot
ExecPreStart=/usr/bin/docker rm lazyfrosch_cloud-cron
ExecStart=/usr/bin/docker run --rm \
    --name lazyfrosch_cloud-cron \
    --link mariadb:mysql \
    -v /data/services/lazyfrosch_cloud/data/apps:/var/www/html/apps \
    -v /data/services/lazyfrosch_cloud/data/data:/var/www/html/data \
    -v /data/services/lazyfrosch_cloud/data/config:/var/www/html/config \
    -u www-data \
    owncloud:8.2 \
    php -d apc.enable_cli=on /var/www/html/cron.php

owncloud-cron.timer

[Unit]
Description=Run every 5 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=5min

[Install]
WantedBy=timers.target

@lazyfrosch
Copy link
Contributor

Benefit of external controlled execution:

  • More configurable
  • no need to fiddle with supervisord stuff
  • log / status from systemd (or fleet)

@mathroc
Copy link
Author

mathroc commented Feb 14, 2016

that's what what I'm doing for now but it's cumbersome to have to manually configure cron externally. Of course if you have specific needs you should be able to disable it and run it your own way. but I guess most people don't really care that much about that.

I'll try to build an image with s6 to run both apache & cron, it should not be too hard and would provide a nicer experience out of the box (especially if using the news app)

@cdauth
Copy link

cdauth commented Feb 25, 2016

What would be the best way to do it?

The easiest way would be to start a background shell in entrypoint.sh that executes the cron every 5 minutes. The probably cleaner way would be to start supervisord.

I could make a pull request, but I'm not sure about the preferred architecture in this repository.

@pierreozoux
Copy link
Contributor

Indeed, I'd be curious to know the taste of the owner of the repo on that matter.
I have the same issue on piwik.
The thing is that cron is horrible inside docker (no output, it wants to send emails...). So a bash loop is the way I guess.

I think I'd prefer a separate container. Especially because there is a default web cron.

@tianon what is your take on that?

@ghost
Copy link

ghost commented Feb 28, 2016

It's also possible to use the cron of the host system:

"docker exec -u www-data [container id or name] php -f /var/www/html/cron.php" should do the job.

@pierreozoux
Copy link
Contributor

Seeing the comment on the piwik discussion I guess we can close the issue.

I found an "elegant" way to solve this from compose:
https://github.com/indiehosters/piwik/blob/master/docker-compose.yml#L29-L36

What do you think?

@mathroc
Copy link
Author

mathroc commented Jul 14, 2016

@pierreozoux I don't think your "docker compose way" solves the issue. it does work, as does en external cron or systemd job but it does not work "out of the box", still needs manual configuration

@pierreozoux
Copy link
Contributor

@mathroc welll, none Docker official image work "out of the box" you always need to wire a database.

I have great hope for the new "store" feature: https://store.docker.com/beta and the Docker App bundle this would allow us to ship artifact that would work "out of the box" for real!

@lazyfrosch
Copy link
Contributor

I actually switched this to exec a while back:

[Unit]
Description=Lazyfrosch.de Owncloud Cronjob
Requires=docker.service
Requires=mariadb.service
Requires=lazyfrosch_cloud.service
After=docker.service
After=mariadb.service
After=lazyfrosch_cloud.service

[Service]
Type=oneshot
ExecStart=/usr/bin/docker exec -u www-data lazyfrosch_cloud php cron.php

With the same timer file as before

@yosifkit
Copy link
Member

Closing given that this image will no longer be updated.

This image has been deprecated in favor of the official owncloud/server image provided, maintained, and supported by ownCloud upstream. The images found here will receive no further updates after 2018-12-31 (Dec 31, 2018). Please adjust your usage accordingly.

- https://github.com/docker-library/owncloud/tree/d815707323e2dce4696a1f7b1639f86fc6bf8b8a#deprecated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants