Code Monkey home page Code Monkey logo

docker-cron's Introduction

A lightweight cron container, which allows crontabs to be specified using environment variables.

This allows for rapid prototyping and development of cron jobs, especially when using docker-compose.

Configuration

Configure the cron container using environment variables. Each environment variable named with the prefix CRON_D_ is linked into /etc/cron.d/, the filename of which will be the environment variables name; e.g.

docker run \
  -e "CRON_D_HELLO_WORLD=* * * * * root echo Hello World from \$(whoami) | logger\n" \
  nickbreen/cron

Will create a file /etc/cron.d/CRON_D_HELLO_WORLD.

Logging

cron jobs are not logged per-se. Instead, if an MTA is available, their output is emailed to the owner of the crontab. Otherwise, the job should explicitly pipe stdout and stderr (with 2>&1) to logger.

This example job echos the value of $HELLO_WORLD or exits with an error and message if it's undefined.

docker run \
  -e 'HELLO_WORLD=Hello World!' \
  -e "CRON_D_HELLO=* *    * * *    root . /etc/container_environment.sh; echo \${HELLO_WORLD:?variable not set} 2>&1 | logger\n" \
  nickbreen/cron:v2.0.0

docker-cron's People

Contributors

nickbreen avatar

Watchers

 avatar  avatar

docker-cron's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.