Last active
July 10, 2023 08:50
-
-
Save AntonFriberg/692eb1a95d61aa001dbb4ab5ce00d291 to your computer and use it in GitHub Desktop.
Simple docker cron sidecar container based on alpine image
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
#!/usr/bin/env sh | |
echo "Job started: $(date)" | |
# Add additional instructions | |
echo "Job finished: $(date)" |
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
FROM alpine:3.8 | |
# Alpine comes with built in cron schedules | |
# min hour day month weekday command | |
# */15 * * * * run-parts /etc/periodic/15min | |
# 0 * * * * run-parts /etc/periodic/hourly | |
# 0 2 * * * run-parts /etc/periodic/daily | |
# 0 3 * * 6 run-parts /etc/periodic/weekly | |
# 0 5 1 * * run-parts /etc/periodic/monthly | |
# Place script in appropriate folder | |
COPY cronscript.sh /etc/periodic/15min/backup | |
# bash-4.4# crond --help | |
# BusyBox v1.28.4 (2018-05-30 10:45:57 UTC) multi-call binary. | |
# Usage: crond -fbS -l N -d N -L LOGFILE -c DIR | |
# -f Foreground | |
# -b Background (default) | |
# -S Log to syslog (default) | |
# -l N Set log level. Most verbose 0, default 8 | |
# -d N Set log level, log to stderr | |
# -L FILE Log to FILE | |
# -c DIR Cron dir. Default:/var/spool/cron/crontabs | |
# This runs cron in the foreground with loglevel 2 | |
CMD [ "crond", "-l", "2", "-f" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can we start the crond with non root user ?