cron_scheduler

Version, currently 0.4.04 versions

github.com/kostya/cron_scheduler

Simple job scheduler with crontab patterns for Crystal Language.

49 stars
1 dependent
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  cron_scheduler:
    github: kostya/cron_scheduler
    version: ~> 0.4.0

Then run:

shards install

shard.yml

Crystal
>= 0.35.1, < 2.0.0
License
MIT
Author
Konstantin Makarchev

Dependencies

Runtime Dependencies

README

# CronScheduler

Simple job scheduler with crontab patterns for Crystal Language.

## Installation


Add this to your application's `shard.yml`:

```yaml
dependencies:
  cron_scheduler:
    github: kostya/cron_scheduler
```


## Usage


```crystal
require "cron_scheduler"
require "logger"

L = Logger.new STDOUT

CronScheduler.define do

  # normal crontab syntax, 5 tokens (minute, hour, day, month, wday)

  at("* * * * *") { L.info "every 1 minute" }
  at("*/5 20-23 * * *") { L.info "every 5 minutes between 20-23 hours" }
  at("*/2 */3 * * *") { L.info "every 2 minute every 3 hours" }
  at("45 * * * *") { L.info "every hour at :45" }
  at("* * * * SUN") { L.info "every 1 minute in sunday" }

  # I added extra syntax, when 6 tokens, first one parsed as seconds
  # (second, minute, hour, day, month, wday)

  at("*/3 * * * * *") { L.info "every 3.seconds" }
  at("20-45/5 * * * * *") { L.info "every 5.seconds between 20-45" }
  at("11,22,33,44-60/2 * * * * *") { L.info "every 11,22,33,44-60/2 seconds" }
end

L.info "Scheduler started"

sleep

```

## Crontab Format

![Eye](http://www.webenabled.com/sites/default/files/crontab-syntax.gif)