Docker Centos7 Container 容器中運行 crontab 定時任務 Dockerfile # Pull base image
FROM centos:latest
MAINTAINER crabdave "calorie.david@gmail.com"
# Usage: USER [UID]
USER root
# modify timezone
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#install cronie
RUN yum -y install cronie
#install crontabs
RUN yum -y install crontabs
RUN sed -i '/session required pam_loginuid.so/c#session required pam_loginuid.so' /etc/pam.d/crond
RUN echo "*/1 * * * * /bin/echo 'it works!' >> /root/test.log" >> /var/spool/cron/root
#start
ENTRYPOINT ["/usr/sbin/init"]
參考:
http://stackoverflow.com/questions/21926465/issues-running-cron-in-docker-on-different-hosts
http://www.linuxadmin.lt/centos-7-no-package-vixie-cron-available/
http://welcomeweb.blog.51cto.com/10487763/1735251
相關資源:Centos 7下利用crontab定時執行任務詳解