diff options
-rw-r--r-- | Dockerfile | 11 | ||||
-rw-r--r-- | Dockerfile_example | 4 | ||||
-rw-r--r-- | README.md | 12 | ||||
-rw-r--r-- | entrypoint.sh | 4 |
4 files changed, 30 insertions, 1 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c8801c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:22.04 +ENV TZ=Europe/London +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update -y +RUN apt-get install -y python3-pip iputils-ping cron git +COPY entrypoint.sh /cron_entrypoint.sh + +ENTRYPOINT ["bash"] +CMD ["/cron_entrypoint.sh"] + + diff --git a/Dockerfile_example b/Dockerfile_example new file mode 100644 index 0000000..552182d --- /dev/null +++ b/Dockerfile_example @@ -0,0 +1,4 @@ +FROM reg.reaweb.uk/cron + +RUN echo "*/1 * * * * root echo '$(date) Hello world' > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/crontab + @@ -1,2 +1,12 @@ # cron -Docker image for running cronjobs, with logging +Docker image for running cronjobs, with logging. + +`docker build -t reg.reaweb.uk/cron . && docker push reg.reaweb.uk/cron` + +## Example `Dockerfile`: + +``` +RUN echo "0 21 * * sat,wed root python3 /app/autoBackup.py > /proc/1/fd/1 2>/proc/1/fd/2" > /etc/crontab +RUN echo "@monthly root python3 /app/autoScrub.py > /proc/1/fd/1 2>/proc/1/fd/2" >> /etc/crontab +``` + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..23b42a8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +# https://stackoverflow.com/questions/27771781/how-can-i-access-docker-set-environment-variables-from-a-cron-job/35088810#35088810 +printenv | grep -v "no_proxy" >> /etc/environment + +cron -f |