Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom cron jobs #1775

Closed
gjedeer opened this issue Jun 22, 2022 · 8 comments
Closed

Allow custom cron jobs #1775

gjedeer opened this issue Jun 22, 2022 · 8 comments

Comments

@gjedeer
Copy link

gjedeer commented Jun 22, 2022

I'm looking for a way to make occ preview:generate-all run periodically in a Docker setup.

Maybe adding a line like this to /var/spool/cron/crontabs/www-data would be a good way to enable using custom cron jobs?

*/5 * * * * if [ -f /var/www/html/cron_custom.sh ]; then bash /var/www/html/cron_custom.sh; fi
@josejsarmento
Copy link

josejsarmento commented Jul 26, 2022

I was looking to execute a periodic job for this exact purpose too. I was hoping for something in the README to teach us how to use the supervisord they embed in the cron Dockerfile example, but I don't understand how to use it.

The next closest thing would be to add in the host a cron job running something like
docker exec --user www-data CONTAINER_ID php occ preview:generate-all

@gjedeer
Copy link
Author

gjedeer commented Jul 26, 2022

I had no idea there's supervisord in there. It can be turned into a poor man's cron with a trick but it's very inflexible when used this way. It can be ran every minute or every hour.

But I think using cron for cron jobs would be better.

@BWibo
Copy link

BWibo commented Oct 9, 2022

I was facing the same issue. For now, I'm using this workaround to run occ preview:generate-all every 15 mins:

The user is member of the docker group: sudo usermod -a -G docker USERNAME

  • User crontag, crontab -e:

    */15 * * * * $HOME/pre-gen.sh > /dev/null 2>&1
  • $HOME/pre-gen.sh

    #!/usr/bin/env bash
    
    echo "--- $(date --utc +%FT%TZ) ----------------------------------------" >>$HOME/pre-generate.log 2>&1
    docker exec -i --user 33 nextcloud-app-1 ./occ preview:pre-generate -v >>$HOME/pre-generate.log 2>&1

@gjedeer
Copy link
Author

gjedeer commented Oct 11, 2022

I'm doing the same but it's a hack.

@jjasoncool
Copy link

#361

@gjedeer
Copy link
Author

gjedeer commented Jan 17, 2023

@jjasoncool yeah, building your own Dockerfile or running cronjobs on the host, not really solutions to the problem.

@jjasoncool
Copy link

jjasoncool commented Jan 18, 2023

You can ref this, build this is running normally.
#1695 (comment)

@J0WI
Copy link
Contributor

J0WI commented Apr 4, 2023

Duplicate of #820

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

No branches or pull requests

5 participants