From 1d0ef14827f35915bd1783e027f1644dd77f6122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Tue, 1 Mar 2022 18:44:09 +0100 Subject: [PATCH] Time Zones --- Dockerfile | 3 +++ README.md | 6 ++++++ libexec/kiwi-cron/run_cron | 4 ++++ 3 files changed, 13 insertions(+) mode change 100644 => 100755 libexec/kiwi-cron/run_cron 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