Skip to content

Instantly share code, notes, and snippets.

@vyspiansky
Created February 15, 2021 14:48
Show Gist options
  • Save vyspiansky/3b62d06c56bc586449e2bda1b288e01a to your computer and use it in GitHub Desktop.
Save vyspiansky/3b62d06c56bc586449e2bda1b288e01a to your computer and use it in GitHub Desktop.
Run cron with supervisor and Docker on Alpine Linux

docker/app/Dockerfile

# ...

# Run a cron job
ADD docker/conf/crontab.txt /crontab.txt
RUN /usr/bin/crontab /crontab.txt

# ...

docker/conf/crontab.txt

*/30 * * * * php /path/to/your/script.php

docker/conf/supervisord.conf

[supervisord]
nodaemon = true
...

[program:cron]
command=/usr/sbin/crond -f
user=root
autostart=true
autorestart=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment