jobwat
3/9/2017 - 4:34 AM

Docker node crontab

Docker node crontab

* * * * * root /usr/local/bin/node /app/test.js >> /var/log/cron.log 2>&1
FROM node:6

RUN apt-get update && apt-get -y install cron

RUN mkdir /app
ADD test.js /app

# Add crontab file in the cron directory
ADD crontab /etc/cron.d/hello-cron

# Give execution rights on the cron job
RUN chmod +x /etc/cron.d/hello-cron

# Create the log file to be able to run tail
RUN touch /var/log/cron.log

# Run the command on container startup
CMD cron && tail -f /var/log/cron.log