funnyzak/cron
a lightweight service that runs in the background and executes scheduled tasks.
293
cron is a lightweight service that runs in the background and executes scheduled tasks. It builds on the official alpine
image and includes dcron
as the cron service. The image is available for multiple architectures, including linux/386
, linux/amd64
, linux/arm/v6
, linux/arm/v7
, linux/arm64/v8
, linux/ppc64le
, linux/riscv64
, linux/s390x
.
Installed packages: dcron
, ca-certificates
, curl
, tar
, tzdata
, bash
, zip
, unzip
, rsync
.
# Docker Hub
docker pull funnyzak/cron:latest
# GitHub Container Registry
docker pull ghcr.io/funnyzak/cron:latest
# Aliyun Registry
docker pull registry.cn-beijing.aliyuncs.com/funnyzak/cron:latest
\n
.mysql-client mariadb-connector-c
.CRON_STRINGS example:
Single job:
# Run every minute
* * * * * /scripts/echo.sh >> /var/log/cron/cron.log 2>&1
Multiple jobs:
# Multiple jobs
* * * * * /scripts/request.sh >> /var/log/cron/cron.log 2>&1\n* * * * * /scripts/echo.sh >> /var/log/cron/cron.log 2>&1
crontab files are located in /etc/cron.d, you can mount a volume to this directory to add your own crontab files.
For example, you can create a file named my-cron
with the following content:
* * * * * /scripts/request.sh >> /var/log/cron/cron.log 2>&1
Note: Default log file should be
/var/log/cron/cron.log
. You should forward all script output to this file.
docker run --name="cron" -d \
-e 'CRON_STRINGS=* * * * * echo "Hi, i am cron." >> /var/log/cron/cron.log 2>&1' \
funnyzak/cron
docker run --name="cron1" -d \
-e 'CRON_STRINGS=* * * * * /scripts/echo.sh >> /var/log/cron/cron.log 2>&1' \
funnyzak/cron
docker run --name="cron2" -d \
-e 'CRON_STRINGS=* * * * * /scripts/echo.sh >> /var/log/cron/cron.log 2>&1' \
-e 'STARTUP_COMMANDS=echo "Hello, World!"' \
-e 'EXTRA_PACKAGES=git' \
funnyzak/cron
docker run --name="cron5" -d \
-e 'CRON_STRINGS=* * * * * /scripts/request.sh >> /var/log/cron/cron.log 2>&1' \
-e 'STARTUP_COMMANDS=/scripts/echo.sh >> /var/log/cron/cron.log 2>&1' \
funnyzak/cron
docker run --name="cron6" -d \
-v ./cron/crontabs:/etc/cron.d \
-v ./cron/scripts:/scripts \
funnyzak/cron
version: '3'
services:
cron:
image: funnyzak/cron
privileged: true
container_name: cron
environment:
- TZ=Asia/Shanghai
- LANG=C.UTF-8
- CRON_TAIL=1
- CRON_STRINGS=* * * * * /scripts/echo.sh >> /var/log/cron/cron.log 2>&1
restart: on-failure
volumes:
- ./cron/scripts:/scripts
- ./cron/crontabs:/etc/cron.d
docker pull funnyzak/cron