dockerfile构建cron任务

FROM ubuntu:latest

RUN apt-get update && \
    apt-get -y install cron tzdata && \
    rm -rf /var/lib/apt/list/* && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    dpkg-reconfigure --frontend noninteractive tzdata

#COPY rm-file.sh /root/rm-file.sh

COPY checklog-cron /etc/cron.d/checklog-cron

#RUN chmod +x /root/rm-file.sh

RUN chmod 0644 /etc/cron.d/checklog-cron

RUN touch /var/log/cron.log

RUN crontab /etc/cron.d/checklog-cron

# Run the command on container startup
CMD cron && tail -f /var/log/cron.log
posted @ 2023-04-12 10:45  whtjyt  阅读(132)  评论(0编辑  收藏  举报