Skip to content

Instantly share code, notes, and snippets.

@mhubig
Last active November 3, 2023 03:42
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save mhubig/a01276e17496e9fd6648cf426d9ceeec to your computer and use it in GitHub Desktop.
Save mhubig/a01276e17496e9fd6648cf426d9ceeec to your computer and use it in GitHub Desktop.
Alpine Linux based cronjob runner
FROM alpine:latest
RUN apk add --update php python py-pip mysql-client \
&& pip install awscli \
&& rm -rf /var/cache/apk/*
RUN touch crontab.tmp \
&& echo '* */6 * * * /usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run' > crontab.tmp \
&& echo '0 2 * * * /usr/bin/sql_backup' >> crontab.tmp \
&& crontab crontab.tmp \
&& rm -rf crontab.tmp
CMD ["/usr/sbin/crond", "-f", "-d", "0"]
Copy link

ghost commented Dec 14, 2016

I am using this cron in multiple images. ++

@zerowebcorp
Copy link

Tested with the latest version, for some reason it doesnt work

/bin/sh: [/usr/sbin/crond,: not found

@juusujanar
Copy link

@getvivekv The last line is at fault, it should be the following:

CMD ["/usr/sbin/crond", "-f", "-d", "0"]

@serhii-bielozorov
Copy link

Thank you, you saved my day. Tested and works on Alpine 3.13 with supervisord.

@nAnderYang
Copy link

log level

/* Log levels:
 * 0 is the most verbose, default 8.
 * For some reason, in fact only 5, 7 and 8 are used.
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment