728x90
https://codeday.me/ko/qa/20190325/152387.html
Cron Job
* * * * * root echo "Hello world" >> /var/log/cron.log 2>&1
Dockerfile
FROM ubuntu:latest
MAINTAINER docker@ekito.fr
RUN apt-get update && apt-get -y install cron
# Add crontab file in the cron directory
ADD crontab /etc/cron.d/hello-cron
# Give execution rights on the cron job
RUN chmod 0644 /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
Build & Excute
sudo docker build --rm -t ekito/cron-example .
sudo docker run -t -i ekito/cron-example
Result
Hello world
Hello world
728x90
'DevOps' 카테고리의 다른 글
<none> 태그 이미지 일괄 삭제 (0) | 2021.07.09 |
---|---|
[docker-compose] Shutdown 스크립트(docker-compose) (0) | 2020.10.22 |
[docker-compose] 커맨드 (0) | 2020.08.16 |
[docker-compose] SpringBoot Application 배포 스크립트(docker-compose 버전) 와탭(Whatap)설정 추가 (0) | 2020.05.03 |
[Docker] SpringBoot Application 배포 스크립트(docker 버전) (0) | 2020.05.01 |
댓글