Code Monkey home page Code Monkey logo

gron's Introduction

gron

Simple cron in Go.

Usage

Use with one or more *.yml files, formatted like so:

cron:
- description: some minutely task
  command: echo minutely; date
  lock: yes

- description: some hourly task
  command: echo hourly; date
  minute: 0
  lock: yes

- description: some daily task
  command: echo daily; date
  hour: 1
  minute: 0

- description: some weekly task
  command: echo weekly; date
  weekday: 0
  hour: 2
  minute: 0

- description: some monthly task
  command: echo monthly; date
  day: 5
  hour: 3
  minute: 0

- description: some hourly task with specific working directory
  command: echo task; pwd; date
  pwd: /tmp
  minute: 0

- description: some minutely task with a 30s timeout
  command: possibly-long-running-command
  timeout: 30  # seconds

Each job will run when the server's wall clock hits the exact specified time. Omitted time constraints mean no constraint.

Weekdays start with 0 (Sunday). 7 is NOT aliased to Sunday.

Command is interpreted with /bin/sh via -c.

pwd specifies command's working directory. It is optional; defaults to gron's own cwd.

Each task runs independently of the others that may have started at the same time - there is no blocking. Failures are simply logged - there is no retry or backoff.

If lock is set to yes (default is no), a simple locking mechanism is used. While an instance of the task is still running, the task will not be re-run. So an hourly task, that runs for 90 minutes, will run 12 times per day.

If you specify timeout, the task will be leashed to run for up to that many seconds, and will get a SIGKILL if it does not complete within these bounds.

All of these features are safe to be combined together.

Pass -d to get more debug spam with nicer formatting.

For things like manipulating the command's environment, dropping privileges, chrooting, etc. refer to the excellent utilities such as env(1), gosu, chpst(1), and so on.

Reporting

You can (optionally) report failing jobs using Sentry. The DSN can be specified by settings the SENTRY_DSN environment variable, or by adding a snippet to one of the config files (which takes precedence):

report:
  SENTRY_DSN: "https://1234:[email protected]/9"
cron:
- description: some job ...

gron's People

Contributors

rollcat avatar

Stargazers

Radu Topala avatar Rafael Escobar avatar

Watchers

James Cloos avatar Damien Seguin avatar Krzysztof Skoracki avatar  avatar  avatar

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.