Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created August 15, 2017 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h2rd/fe73f565e8f2e40f4e06e003f2a60cde to your computer and use it in GitHub Desktop.
Save h2rd/fe73f565e8f2e40f4e06e003f2a60cde to your computer and use it in GitHub Desktop.
0 1 * * * root . /root/envs.sh;/bin/backup.sh >> /var/log/cron.log 2>&1
FROM ubuntu:latest
ADD start.sh /bin/start.sh
RUN chmod +x /bin/start.sh
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/thecron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/thecron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# start script
CMD /bin/bash /bin/start.sh
# export all environment variables to use in cron
env | sed 's/^\(.*\)$/export \1/g' > /root/envs.sh
chmod +x /root/envs.sh
# Run the command on container startup
cron && tail -f /var/log/cron.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment