Replicated doesn’t natively support cron as part of application config, but depending on the scheduler used, there are some very stable options for building cron behavior into your app.
Kubernetes
For apps using Replicated + Kubernetes, we recommend the Kubernetes CronJob Resource.
Swarm and others
For other apps, we recommend using supercronic
Supercronic Example
This example shows how to write an app component to curl a URL at various intervals using supercronic, also showcasing the use of loading variables from the container’s environment.
crontab
19 * * * * curl -d "{}" http://${NSQD_HOST}/pub?topic=nineteen_past_hour
*/10 * * * * curl -d "{}" http://${NSQD_HOST}/pub?topic=every_ten_minutes
dockerfile
FROM debian:stretch-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64
ENV SUPERCRONIC=supercronic-linux-amd64
ENV SUPERCRONIC_SHA1SUM=96960ba3207756bb01e6892c978264e5362e117e
RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic
COPY ./crontab /crontab
CMD /bin/bash -c '/usr/local/bin/supercronic /crontab &> /dev/null'