Documentation Docs

Cron, scheduled tasks

You can enable cron/recurring jobs by using cron and crontab. This is however something not officially available, but you can configure yourself.


See below an example Dockerfile with a cron job running every minute:

FROM node:16-alpine

WORKDIR /opt/app


# daemon for cron jobs
RUN echo 'crond' > / # <-----
RUN echo 'crontab .openode.cron' >> / # <-----

COPY package*.json ./

RUN npm install --production

# Bundle app source
COPY . .

CMD sh / && npm start # <-----

The relevant lines are just below "daemon for cron jobs" and the last line ensure to active it at boot time.

.openode.cron file

The crontab format can be used. See below an example cron file:

* * * * * cd /opt/app ; node cronjob.js >> out.txt