Last active
January 9, 2023 07:40
-
-
Save vnext-nguyen-quyen/eb97f19381dec585522c253dc23399b0 to your computer and use it in GitHub Desktop.
See cron log ouput with docker logs
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
1. Alpine (No need for redirection) | |
using the default cron utility (busybox) | |
## Dockerfile | |
===== | |
FROM alpine:3.7 | |
# Setting up crontab | |
COPY crontab /tmp/crontab | |
RUN cat /tmp/crontab > /etc/crontabs/root | |
CMD ["crond", "-f", "-l", "2"] | |
===== | |
## Crontab | |
===== | |
* * * * * echo "Crontab is working - watchdog 1" | |
===== | |
2. Centos | |
Redirection to /proc/1/fd/1 inside the crontab declaration line | |
## Dockerfile | |
===== | |
FROM centos:7 | |
RUN yum -y install crontabs | |
ADD crontab /etc/cron.d/crontab | |
RUN chmod 0644 /etc/cron.d/crontab | |
RUN crontab /etc/cron.d/crontab | |
CMD ["crond", "-n"] | |
===== | |
## Crontab | |
===== | |
* * * * * echo "Crontab is working - watchdog 1" > /proc/1/fd/1 | |
===== | |
=> Test show cron ouput with docker logs {container_name} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment