Created
March 9, 2017 04:34
-
-
Save jobwat/e15e2dc740792ef51723096cad38ed3c to your computer and use it in GitHub Desktop.
Docker node crontab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* * * * * root /usr/local/bin/node /app/test.js >> /var/log/cron.log 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Yo'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't forget to apply a cron job:
RUN crontab /etc/cron.d/hello-cron