1
0
mirror of https://github.com/Luzifer/elastic_cron.git synced 2024-09-16 13:48:37 +00:00
This project is a quick and dirty replacement for running a cron daemon inside docker containers
Go to file
2018-04-15 14:07:05 +02:00
vendor Add dependencies 2018-04-15 14:06:54 +02:00
.gitignore Convert to elasticsearch logging 2018-04-15 13:54:39 +02:00
.repo-runner.yaml Cleanup for switching to elasticsearch 2018-04-15 12:28:05 +02:00
config.yml Convert to elasticsearch logging 2018-04-15 13:54:39 +02:00
CONTRIBUTING.md Add meta files 2017-04-02 14:12:09 +02:00
Gopkg.lock Add dependencies 2018-04-15 14:06:54 +02:00
Gopkg.toml Add dependencies 2018-04-15 14:06:54 +02:00
History.md prepare release v1.0.1 2018-04-15 14:07:05 +02:00
LICENSE Cleanup for switching to elasticsearch 2018-04-15 12:28:05 +02:00
main.go Convert to elasticsearch logging 2018-04-15 13:54:39 +02:00
Makefile Add building for Github releases 2017-04-02 14:27:21 +02:00
README.md Add dependencies 2018-04-15 14:06:54 +02:00

Luzifer / elastic_cron

This project is a quick and dirty replacement for running a cron daemon inside docker containers while logging into an elasticsearch instance.

The code is basically a fork of the rsyslog_cron repo modified to log into elasticsearch.

Advantages

  • It logs the output of the jobs into an elasticsearch instance
  • Crons can be started on seconds, not only on minutes like a conventional cron
  • Due to the logs cron jobs can get debugged
  • On success and failure a HTTP ping to Healthchecks or Cronitor can be executed

Usage

  1. Put the binary into your container
  2. Generate a YAML file containing the cron definition
  3. Watch your crons get executed in your log stream

Config format

---

elasticsearch:
  index: 'elastic_cron-%{+YYYY.MM.dd}'
  servers:
    - http://localhost:9200
  auth: [username, password]

jobs:
  - name: date
    schedule: "0 * * * * *"
    cmd: "/bin/date"
    args:
      - "+%+"
    ping_success: "https://..."
    ping_failure: "https://..."

...
  • elasticsearch
    • index - Name of the index to write messages to (understands same date specifier as ES beats)
    • servers - List of elasticsearch instances of the same cluster to log to
    • auth - List consisting of two elements: username and password
  • schedule - consists of 6 instead of the normal 5 fields:
field         allowed values
-----         --------------
second        0-59
minute        0-59
hour          0-23
day of month  1-31
month         1-12 (or names, see below)
day of week   0-7 (0 or 7 is Sun, or use names)

Standard format for crontab entries is supported. (See man 5 crontab)