1
0
Fork 0
mirror of https://github.com/Luzifer/elastic_cron.git synced 2024-11-09 14:19:59 +00:00
elastic_cron/README.md

61 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

2018-04-15 10:28:05 +00:00
# Luzifer / elastic\_cron
2016-02-26 21:31:51 +00:00
2018-04-15 10:28:05 +00:00
This project is a quick and dirty replacement for running a cron daemon inside docker containers while logging into an elasticsearch instance.
2016-02-26 21:31:51 +00:00
The code is basically a fork of the [rsyslog\_cron](https://github.com/Luzifer/rsyslog_cron) repo modified to log into elasticsearch.
2016-02-26 21:31:51 +00:00
## Advantages
2018-04-15 10:28:05 +00:00
- It logs the output of the jobs into an elasticsearch instance
2016-02-26 21:31:51 +00:00
- 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](https://healthchecks.io/) or [Cronitor](https://cronitor.io/) can be executed
2016-02-26 21:31:51 +00:00
## Usage
2018-04-15 10:28:05 +00:00
1. Put the [binary](https://github.com/Luzifer/elastic_cron/releases/latest) into your container
2016-02-26 21:31:51 +00:00
2. Generate a YAML file containing the cron definition
3. Watch your crons get executed in your log stream
## Config format
```yaml
---
2018-04-15 10:28:05 +00:00
elasticsearch:
2018-04-15 11:54:39 +00:00
index: 'elastic_cron-%{+YYYY.MM.dd}'
2018-04-15 10:28:05 +00:00
servers:
- http://localhost:9200
auth: [username, password]
2016-02-26 21:31:51 +00:00
jobs:
- name: date
schedule: "0 * * * * *"
cmd: "/bin/date"
args:
- "+%+"
ping_success: "https://..."
ping_failure: "https://..."
2018-04-15 10:28:05 +00:00
...
2016-02-26 21:31:51 +00:00
```
2018-04-15 10:28:05 +00:00
- `elasticsearch`
2018-04-15 11:54:39 +00:00
- `index` - Name of the index to write messages to (understands same date specifier as ES beats)
2018-04-15 10:28:05 +00:00
- `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:
2016-02-26 21:31:51 +00:00
```
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`)