1
0
Fork 0
mirror of https://github.com/yavook/kiwi-cron.git synced 2024-11-21 15:03:01 +00:00
kiwi-cron/README.md

50 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

2022-02-24 17:16:01 +00:00
# kiwi-cron
2022-02-27 15:45:03 +00:00
[![Build Status](https://github.drone.yavook.de/api/badges/yavook/kiwi-cron/status.svg)](https://github.drone.yavook.de/yavook/kiwi-cron)
2022-02-24 17:16:01 +00:00
> `kiwi` - simple, consistent, powerful
2022-02-27 15:45:03 +00:00
Simple cron-jobs for [`kiwi-scp`](https://github.com/yavook/kiwi-scp)
2022-02-24 17:16:01 +00:00
## Quick start
2022-02-25 16:24:50 +00:00
`kiwi-cron` comes with a (slightly) opinionated `cron` daemon config for periodic jobs.
Just drop your scripts into the relevant directory under `/kiwi-cron`, that's it.
2022-02-25 00:57:52 +00:00
2022-02-25 16:24:50 +00:00
You will likely want to automate some tasks regarding your `docker` infrastructure.
That's why the `kiwi-cron` images package a current `docker-cli` you can just mount your `docker.sock` in its containers and use `docker` commands normally.
2022-02-25 00:57:52 +00:00
2022-03-02 23:25:45 +00:00
## 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".
2022-02-25 16:24:50 +00:00
## Simple jobs
2022-02-25 00:57:52 +00:00
2022-02-25 16:24:50 +00:00
On startup, `kiwi-cron` checks for possible job files in the `/kiwi-cron` directory structure.
2022-02-25 00:57:52 +00:00
2022-02-25 16:24:50 +00:00
For each subdirectory, a random valid cron schedule is generated, so that:
- `/kiwi-cron/hourly` runs once every hour (random minute)
2022-03-02 23:25:45 +00:00
- `/kiwi-cron/daily` runs once every day (random nighttime value between 9 pm and 3 am)
2022-02-25 16:24:50 +00:00
- `/kiwi-cron/weekly` runs once every weekend (random nighttime value on Saturday or Sunday)
2022-03-02 23:25:45 +00:00
- `/kiwi-cron/monthly` runs once every month (random nighttime value on a random day <= 28)
- `/kiwi-cron/yearly` and `/kiwi-cron/annually` runs once a year (random nighttime value on a random day <= 28 in January or February)
2022-02-25 16:24:50 +00:00
Cron schedules are regenerated once on each startup, only for directories that have files.
2022-03-02 23:25:45 +00:00
## Granularity: The `/kiwi-cron/every` directory
2022-02-25 16:24:50 +00:00
Directories like `/kiwi-cron/every/5_minutes` will run scripts every 5 minutes.
`kiwi-cron` picks up on that format and generates valid `cron` schedules on startup.
2022-03-02 23:25:45 +00:00
This way, you can define schedules to be run every N minutes, hours, days, or months by creating the corresponding directories.
2022-02-25 16:24:50 +00:00
2022-03-02 23:25:45 +00:00
Scheduling for every N weeks (or years) doesn't work though; jobs in those directories will instead be run every week (or every year).
2022-02-25 16:24:50 +00:00
## Inspection
Checking the generated `cron` schedules is done using the standard `crontab` command:
`docker exec kiwi-cron-container crontab -l` will show the effective schedules.