diff --git a/Dockerfile b/Dockerfile index 0b29a95..57569c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM alpine:latest +ENV TZ=Etc/UTC + RUN set -ex; \ \ mkdir -pm 755 /kiwi-cron; \ @@ -16,6 +18,7 @@ RUN set -ex; \ \ apk --no-cache add \ docker-cli \ + tzdata \ ; COPY bin /usr/local/bin/ diff --git a/README.md b/README.md index 141c7a5..fe0507d 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ For each subdirectory, a random valid cron schedule is generated, so that: Cron schedules are regenerated once on each startup, only for directories that have files. +## Time Zones + +`kiwi-cron` images include the `tzdata` package and automatically handle `/etc/localtime` on startup. By default, "Etc/UTC" is set as the container time zone. + +To use a different time zone, change the container environment variable `TZ` to your liking, e.g. "Europe/Berlin". + ## Finer granularity: The `/kiwi-cron/every` directory Directories like `/kiwi-cron/every/5_minutes` will run scripts every 5 minutes. diff --git a/libexec/kiwi-cron/run_cron b/libexec/kiwi-cron/run_cron old mode 100644 new mode 100755 index 347aabb..8bfe7eb --- a/libexec/kiwi-cron/run_cron +++ b/libexec/kiwi-cron/run_cron @@ -1,5 +1,9 @@ #!/bin/sh +# set timezone +export TZ="${TZ:-Etc/UTC}" +ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime" + # check for CLI options while getopts ':n' rc_optarg; do case "${rc_optarg}" in