All Projects → jshmrtn → Crontab

jshmrtn / Crontab

Licence: mit
Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Crontab

delay-timer
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible scheduling, and dynamic add/cancel/remove is supported.
Stars: ✭ 257 (+314.52%)
Mutual labels:  cron, schedule, crontab
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+172.58%)
Mutual labels:  cron, schedule, crontab
watchman
📆 更夫(watchman)是一款可视化的定时任务配置 Web 工具,麻麻不用担心我漏掉任何更新啦!
Stars: ✭ 40 (-35.48%)
Mutual labels:  cron, schedule, crontab
Crono
A time-based background job scheduler daemon (just like Cron) for Rails
Stars: ✭ 637 (+927.42%)
Mutual labels:  cron, schedule
Ncrontab
Crontab for .NET
Stars: ✭ 566 (+812.9%)
Mutual labels:  schedule, crontab
Gocron
Easy and fluent Go cron scheduling. This is a fork from https://github.com/jasonlvhit/gocron
Stars: ✭ 605 (+875.81%)
Mutual labels:  cron, schedule
crony
Manage remote crontabs from your terminal
Stars: ✭ 12 (-80.65%)
Mutual labels:  cron, crontab
Cron Parser
Node.js library for parsing crontab instructions
Stars: ✭ 802 (+1193.55%)
Mutual labels:  cron, crontab
Cron Utils
Cron utils for parsing, validations and human readable descriptions as well as date/time interoperability.
Stars: ✭ 724 (+1067.74%)
Mutual labels:  cron, crontab
Go Crond
⏰ Cron daemon written in golang (for eg. usage in docker images)
Stars: ✭ 59 (-4.84%)
Mutual labels:  cron, crontab
Bree
🚥 The best job scheduler for Node.js and JavaScript with cron, dates, ms, later, and human-friendly support. Works in Node v10+ and browsers, uses workers to spawn sandboxed processes, and supports async/await, retries, throttling, concurrency, and graceful shutdown. Simple, fast, and lightweight. Made for @ForwardEmail and @ladjs.
Stars: ✭ 933 (+1404.84%)
Mutual labels:  cron, crontab
Wecron
✔️ 微信上的定时提醒 - Cron on WeChat
Stars: ✭ 537 (+766.13%)
Mutual labels:  cron, crontab
Chronos
Fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules
Stars: ✭ 4,303 (+6840.32%)
Mutual labels:  cron, crontab
Agendash
Agenda Dashboard
Stars: ✭ 620 (+900%)
Mutual labels:  cron, crontab
Gocron
定时任务管理系统
Stars: ✭ 4,198 (+6670.97%)
Mutual labels:  cron, crontab
Dynamic Wallpaper
A simple bash script to set wallpapers according to current time, using cron job scheduler.
Stars: ✭ 762 (+1129.03%)
Mutual labels:  cron, crontab
Mantra
A simple cron-like scheduler for a single command
Stars: ✭ 24 (-61.29%)
Mutual labels:  cron, schedule
Vue Cron Generator
Cron Generator Implemented by Vue.js and Element-ui(基于Vue&Element-UI构建的在线Cron表达式生成器)
Stars: ✭ 48 (-22.58%)
Mutual labels:  cron, crontab
Cronicle
A simple, distributed task scheduler and runner with a web based UI.
Stars: ✭ 979 (+1479.03%)
Mutual labels:  cron, crontab
php-cron-expr
Ultra lightweight, Dependency free and Super Fast Cron Expression parser for PHP
Stars: ✭ 42 (-32.26%)
Mutual labels:  cron, crontab

Crontab

CI Coverage Status Module Version Hex Docs Total Download License Last Updated

Elixir library for parsing, writing, and calculating Cron format strings.

Installation

Add :crontab to your list of dependencies in mix.exs:

def deps do
  [
    {:crontab, "~> 1.1"}
  ]
end

For Elixir version before 1.4, ensure :crontab is started before your application:

def application do
  [
    applications: [:crontab]
  ]
end

Usage

Import Cron expression sigil

Everywhere you want to use the Cron expression sigil (e[cron expression]).

import Crontab.CronExpression

Extended Cron expressions

An extended Cron expression has more precision than a normal Cron expression. It also specifies the second.

If you want to use extended Cron expressions with the sigil, just append an e.

Checking if a Cron Expression Matches a date

iex> import Crontab.CronExpression
iex> Crontab.DateChecker.matches_date?(~e[*/2], ~N[2017-01-01 01:01:00])
false
iex> Crontab.DateChecker.matches_date?(~e[*], ~N[2017-01-01 01:01:00])
true

Find Next / Previous Execution Date candidates

All the date parameters default to now.

For previous, just replace next in the code below.

iex> import Crontab.CronExpression
iex> Crontab.Scheduler.get_next_run_date(~e[*/2], ~N[2017-01-01 01:01:00])
{:ok, ~N[2017-01-01 01:02:00]}
iex> Crontab.Scheduler.get_next_run_date!(~e[*/2], ~N[2017-01-01 01:01:00])
~N[2017-01-01 01:02:00]
iex> Crontab.Scheduler.get_next_run_dates(3, ~e[*/2], ~N[2017-01-01 01:01:00])
{:ok,
 [~N[2017-01-01 01:02:00], ~N[2017-01-01 01:04:00], ~N[2017-01-01 01:06:00]]}
iex> Crontab.Scheduler.get_next_run_dates!(3, ~e[*/2], ~N[2017-01-01 01:01:00])
[~N[2017-01-01 01:02:00], ~N[2017-01-01 01:04:00], ~N[2017-01-01 01:06:00]]

Parse Cron Expressions

If you statically define cron expressions, use the ~e[cron expression] sigil.

For dynamic cron expressions, there is a Parser module.

The parser module takes an optional extended flag. This is to mark if the expression contains seconds. This defaults to false.

iex> Crontab.CronExpression.Parser.parse "* * * * *"
{:ok,
  %Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
  month: [:*], weekday: [:*], year: [:*]}}
iex> Crontab.CronExpression.Parser.parse! "* * * * *"
%Crontab.CronExpression{day: [:*], hour: [:*], minute: [:*],
 month: [:*], weekday: [:*], year: [:*]}

Compose Cron expressions

iex> Crontab.CronExpression.Composer.compose %Crontab.CronExpression{}
"* * * * * *"
iex> Crontab.CronExpression.Composer.compose %Crontab.CronExpression{minute: [9, {:-, 4, 6}, {:/, :*, 9}]}
"9,4-6,*/9 * * * * *"

Copyright and License

Copyright (c) 2016, SK & T AG, JOSHMARTIN GmbH, Jonatan Männchen

This library is MIT licensed. See the LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].