All Projects → willfarrell → Docker Crontab

willfarrell / Docker Crontab

Licence: mit
A docker job scheduler (aka. crontab for docker)

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Docker Crontab

Zeit
Qt frontend to at & crontab CLI utilities
Stars: ✭ 42 (-73.58%)
Mutual labels:  crontab
Ppgo job
PPGo_Job是一款可视化的、多人多权限的、一任务多机执行的定时任务管理系统,采用golang开发,安装方便,资源消耗少,支持大并发,可同时管理多台服务器上的定时任务。
Stars: ✭ 1,152 (+624.53%)
Mutual labels:  crontab
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (-25.79%)
Mutual labels:  crontab
Vue Cron Generator
Cron Generator Implemented by Vue.js and Element-ui(基于Vue&Element-UI构建的在线Cron表达式生成器)
Stars: ✭ 48 (-69.81%)
Mutual labels:  crontab
How To Mine Newsfeed Data And Extract Interactive Insights In Python
A practical guide to topic mining and interactive visualizations
Stars: ✭ 61 (-61.64%)
Mutual labels:  crontab
Cronmon
定时任务执行状态监控
Stars: ✭ 90 (-43.4%)
Mutual labels:  crontab
Cronicle
A simple, distributed task scheduler and runner with a web based UI.
Stars: ✭ 979 (+515.72%)
Mutual labels:  crontab
Ects
Elastic Crontab System 简单易用的分布式定时任务管理系统
Stars: ✭ 156 (-1.89%)
Mutual labels:  crontab
Crontab
Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.
Stars: ✭ 62 (-61.01%)
Mutual labels:  crontab
Crontab Ui
Easy and safe way to manage your crontab file
Stars: ✭ 1,786 (+1023.27%)
Mutual labels:  crontab
Jiacrontab
简单可信赖的任务管理工具
Stars: ✭ 1,052 (+561.64%)
Mutual labels:  crontab
Go Crond
⏰ Cron daemon written in golang (for eg. usage in docker images)
Stars: ✭ 59 (-62.89%)
Mutual labels:  crontab
Job
JOB, make your short-term command as a long-term job. 将命令行规划成任务的工具
Stars: ✭ 98 (-38.36%)
Mutual labels:  crontab
Crontab
⏰ Cron expression generator
Stars: ✭ 44 (-72.33%)
Mutual labels:  crontab
Quantum Core
⌚ Cron-like job scheduler for Elixir
Stars: ✭ 1,905 (+1098.11%)
Mutual labels:  crontab
Routine
go routine control, abstraction of the Main and some useful Executors.如果你不会管理Goroutine的话,用它
Stars: ✭ 40 (-74.84%)
Mutual labels:  crontab
Krontab
⏰ A crontab like editor for Kubernetes cron jobs
Stars: ✭ 90 (-43.4%)
Mutual labels:  crontab
Firemotd
🔥 Fire Framework Linux MoTD Generator 🔥
Stars: ✭ 156 (-1.89%)
Mutual labels:  crontab
Gophercron
golang 开箱即用的秒级分布式定时任务系统
Stars: ✭ 146 (-8.18%)
Mutual labels:  crontab
Crontabmanager
PHP library for GNU/Linux cron jobs management.
Stars: ✭ 113 (-28.93%)
Mutual labels:  crontab

docker-crontab

A simple wrapper over docker to all complex cron job to be run in other containers.

Supported tags and Dockerfile links

Why?

Yes, I'm aware of mcuadros/ofelia (>250MB when this was created), it was the main inspiration for this project. A great project, don't get me wrong. It was just missing certain key enterprise features I felt were required to support where docker is heading.

Features

  • Easy to read schedule syntax allowed.
  • Allows for comments, cause we all need friendly reminders of what update_script.sh actually does.
  • Start an image using image.
  • Run command in a container using container.
  • Run command on a instances of a scaled container using project.
  • Ability to trigger scripts in other containers on completion cron job using trigger.

Config file

The config file can be specifed in any of json, toml, or yaml, and can be defined as either an array or mapping (top-level keys will be ignored; can be useful for organizing commands)

  • name: Human readable name that will be used as the job filename. Will be converted into a slug. Optional.
  • comment: Comments to be included with crontab entry. Optional.
  • schedule: Crontab schedule syntax as described in https://en.wikipedia.org/wiki/Cron. Ex @hourly, @every 1h30m, * * * * *. Required.
  • command: Command to be run on in crontab container or docker container/image. Required.
  • image: Docker images name (ex library/alpine:3.5). Optional.
  • project: Docker Compose/Swarm project name. Optional, only applies when contain is included.
  • container: Full container name or container alias if project is set. Ignored if image is included. Optional.
  • dockerargs: Command line docker run/exec arguments for full control. Defaults to .
  • trigger: Array of docker-crontab subset objects. Subset includes: image,project,container,command,dockerargs
  • onstart: Run the command on crontab container start, set to true. Optional, defaults to falsey.

See config-samples for examples.

[{
 	"schedule":"@every 5m",
 	"command":"/usr/sbin/logrotate /etc/logrotate.conf"
 },{
 	"comment":"Regenerate Certificate then reload nginx",
 	"schedule":"43 6,18 * * *",
 	"command":"sh -c 'dehydrated --cron --out /etc/ssl --domain ${LE_DOMAIN} --challenge dns-01 --hook dehydrated-dns'",
 	"dockerargs":"--env-file /opt/crontab/env/letsencrypt.env -v webapp_nginx_tls_cert:/etc/ssl -v webapp_nginx_acme_challenge:/var/www/.well-known/acme-challenge",
 	"image":"willfarrell/letsencrypt",
 	"trigger":[{
 		"command":"sh -c '/etc/scripts/make_hpkp ${NGINX_DOMAIN} && /usr/sbin/nginx -t && /usr/sbin/nginx -s reload'",
 		"project":"conduit",
 		"container":"nginx"
 	}],
 	"onstart":true
 }]

How to use

Command Line

docker build -t crontab .
docker run -d \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    -v ./env:/opt/env:ro \
    -v /path/to/config/dir:/opt/crontab:rw \
    -v /path/to/logs:/var/log/crontab:rw \
    crontab

Use with docker-compose

  1. Figure out which network name used for your docker-compose containers
    • use docker network ls to see existing networks
    • if your docker-compose.yml is in my_dir directory, you probably has network my_dir_default
    • otherwise read the docker-compose docs
  2. Add dockerargs to your docker-crontab config.json
    • use --network NETWORK_NAME to connect new container into docker-compose network
    • use --rm --name NAME to use named container
    • e.g. "dockerargs": "--network my_dir_default --rm --name my-best-cron-job"

Dockerfile

FROM willfarrell/crontab

COPY config.json ${HOME_DIR}/

Logrotate Dockerfile

FROM willfarrell/crontab

RUN apk add --no-cache logrotate
RUN echo "*/5 *	* * *  /usr/sbin/logrotate /etc/logrotate.conf" >> /etc/crontabs/logrotate
COPY logrotate.conf /etc/logrotate.conf

CMD ["crond", "-f"]

Logging - In Dev

All stdout is captured, formatted, and saved to /var/log/crontab/jobs.log. Set LOG_FILE to /dev/null to disable logging.

example: e6ced859-1563-493b-b1b1-5a190b29e938 2017-06-18T01:27:10+0000 [info] Start Cronjob **map-a-vol** map a volume

grok: CRONTABLOG %{DATA:request_id} %{TIMESTAMP_ISO8601:timestamp} \[%{LOGLEVEL:severity}\] %{GREEDYDATA:message}

TODO

  • [ ] Have ability to auto regenerate crontab on file change (signal HUP?)
  • [ ] Run commands on host machine (w/ --privileged?)
  • [ ] Write tests
  • [ ] Setup TravisCI
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].