All Projects → adhocore → php-cron-expr

adhocore / php-cron-expr

Licence: MIT License
Ultra lightweight, Dependency free and Super Fast Cron Expression parser for PHP

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-cron-expr

gronx
Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage
Stars: ✭ 206 (+390.48%)
Mutual labels:  crontab, scheduler, cron-expression, cron-parser, adhocore
Automation-using-Shell-Scripts
Development Automation using Shell Scripting.
Stars: ✭ 41 (-2.38%)
Mutual labels:  cron, crontab, scheduler
crontab
cron expression parser and executor for dotnet core.
Stars: ✭ 13 (-69.05%)
Mutual labels:  cron, crontab, cron-expression
Gocron
定时任务管理系统
Stars: ✭ 4,198 (+9895.24%)
Mutual labels:  cron, crontab, scheduler
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 (+2121.43%)
Mutual labels:  cron, crontab, scheduler
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+302.38%)
Mutual labels:  cron, crontab, scheduler
Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (+180.95%)
Mutual labels:  cron, crontab, scheduler
Deno cron
A cron Job scheduler for Deno that allows you to write human readable cron syntax with tons of flexibility
Stars: ✭ 35 (-16.67%)
Mutual labels:  cron, crontab, scheduler
Cronicle
A simple, distributed task scheduler and runner with a web based UI.
Stars: ✭ 979 (+2230.95%)
Mutual labels:  cron, crontab, scheduler
Quantum Core
⌚ Cron-like job scheduler for Elixir
Stars: ✭ 1,905 (+4435.71%)
Mutual labels:  cron, crontab, scheduler
asparagus
An easy to use task scheduler for distributed systems
Stars: ✭ 14 (-66.67%)
Mutual labels:  cron, crontab, scheduler
cron-time
Javascript Cron Time Expressions
Stars: ✭ 58 (+38.1%)
Mutual labels:  cron, cron-expression
php-json-fixer
Fix truncated JSON data
Stars: ✭ 37 (-11.9%)
Mutual labels:  adhocore, hacktoberfest2021
cronitor-cli
Command line tools for Cronitor.io
Stars: ✭ 31 (-26.19%)
Mutual labels:  cron, crontab
rhythm
Time-based job scheduler for Apache Mesos
Stars: ✭ 30 (-28.57%)
Mutual labels:  cron, scheduler
linda
Linda is a simple dispatcher library.
Stars: ✭ 12 (-71.43%)
Mutual labels:  cron, scheduler
croncal
Utility to convert a crontab file to a list of actual events within a date range.
Stars: ✭ 37 (-11.9%)
Mutual labels:  cron, crontab
watchman
📆 更夫(watchman)是一款可视化的定时任务配置 Web 工具,麻麻不用担心我漏掉任何更新啦!
Stars: ✭ 40 (-4.76%)
Mutual labels:  cron, crontab
php-underscore
PHP underscore inspired &/or cloned from _.js, with extra goodies like higher order messaging
Stars: ✭ 42 (+0%)
Mutual labels:  adhocore, hacktoberfest2021
php-env
A small and fast .env loader for PHP
Stars: ✭ 19 (-54.76%)
Mutual labels:  adhocore, hacktoberfest2021

adhocore/cron-expr

Latest Version Travis Build Scrutinizer CI Codecov branch StyleCI Software License Donate 15 Donate 25 Donate 50 Tweet

  • Lightweight Cron expression parser library for PHP.
  • Zero dependency.
  • Very fast because it bails early in case a segment doesnt match.
  • Real benchmark shows it is about 7.54x to 12.92x faster than dragonmantank/cron-expression

Installation

composer require adhocore/cron-expr

# PHP5.6 or lower
composer require adhocore/cron-expr:0.1.0

Usage

Basic

use Ahc\Cron\Expression;
use Ahc\Cron\Normalizer;

Expression::isDue('@always');
Expression::isDue(Normalizer::HOURLY, '2015-01-01 00:00:00');
Expression::isDue('*/20 * * * *', new DateTime);
Expression::isDue('5-34/4 * * * *', time());

// Dont like static calls? Below is possible too!
$expr = new Expression;
$expr->isCronDue('*/1 * * * *', time());

Bulk checks

When checking for several jobs at once, if more than one of the jobs share equivalent expression then the evaluation is done only once per go thus greatly improving performnce.

use Ahc\Cron\Expression;

$jobs = [
    'job1' => '*/2 */2 * * *',
    'job1' => '* 20,21,22 * * *',
    'job3' => '7-9 * */9 * *',
    'job4' => '*/5 * * * *',
    'job5' => '@5minutes',     // equivalent to job4 (so it is due if job4 is due)
    'job6' => '7-9 * */9 * *', // exact same as job3 (so it is due if job3 is due)
];

// The second param $time can be used same as above: null/time()/date string/DateTime
$dues = Expression::getDues($jobs, '2015-08-10 21:50:00');
// ['job1', 'job4', 'job5']

// Dont like static calls? Below is possible too!
$expr = new Expression;
$dues = $expr->filter($jobs, time());

Cron Expression

Cron expression normally consists of 5 segments viz:

<minute> <hour> <day> <month> <weekday>

and sometimes there can be 6th segment for <year> at the end.

Real Abbreviations

You can use real abbreviations for month and week days. eg: JAN, dec, fri, SUN

Tags

Following tags are available and they are converted to real cron expressions before parsing:

  • @yearly or @annually - every year
  • @monthly - every month
  • @daily - every day
  • @weekly - every week
  • @hourly - every hour
  • @5minutes - every 5 minutes
  • @10minutes - every 10 minutes
  • @15minutes - every 15 minutes
  • @30minutes - every 30 minutes
  • @always - every minute

You can refer them with constants from Ahc\Cron\Normalizer like Ahc\Cron\Normalizer::WEEKLY

Modifiers

Following modifiers supported

  • Day of Month / 3rd segment:
    • L stands for last day of month (eg: L could mean 29th for February in leap year)
    • W stands for closest week day (eg: 10W is closest week days (MON-FRI) to 10th date)
  • Day of Week / 5th segment:
    • L stands for last weekday of month (eg: 2L is last monday)
    • # stands for nth day of week in the month (eg: 1#2 is second sunday)

LICENSE

© MIT | 2017-2019, Jitendra Adhikari

Credits

This project is release managed by please.

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].