Skip to content

Instantly share code, notes, and snippets.

@jobwat
Created March 9, 2017 04:34
Show Gist options
  • Save jobwat/e15e2dc740792ef51723096cad38ed3c to your computer and use it in GitHub Desktop.
Save jobwat/e15e2dc740792ef51723096cad38ed3c to your computer and use it in GitHub Desktop.
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
console.log('Yo');
@funnydman
Copy link

Don't forget to apply a cron job: RUN crontab /etc/cron.d/hello-cron

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