Home

Awesome

<h1 align="center"> <img src="https://github.com/orisai/.github/blob/main/images/repo_title.png?raw=true" alt="Orisai"/> <br/> Scheduler </h1> <p align="center"> Cron job scheduler - with locks, parallelism and more </p> <p align="center"> šŸ“„ Check out our <a href="docs/README.md">documentation</a>. </p> <p align="center"> šŸ’ø If you like Orisai, please <a href="https://orisai.dev/sponsor">make a donation</a>. Thank you! </p> <p align="center"> <a href="https://github.com/orisai/scheduler/actions?query=workflow:CI+branch:v2.x"><img src="https://github.com/orisai/scheduler/actions/workflows/ci.yaml/badge.svg?branch=v2.x"></a> <a href="https://coveralls.io/github/orisai/scheduler?branch=v2.x"><img src="https://badgen.net/coveralls/c/github/orisai/scheduler/v2.x?cache=300"></a> <a href="https://dashboard.stryker-mutator.io/reports/github.com/orisai/scheduler/v2.x"><img src="https://img.shields.io/endpoint?style=flat&url=https://badge-api.stryker-mutator.io/github.com/orisai/scheduler/v2.x"></a> <a href="https://packagist.org/packages/orisai/scheduler"><img src="https://badgen.net/packagist/dt/orisai/scheduler?cache=3600"></a> <a href="https://packagist.org/packages/orisai/scheduler"><img src="https://badgen.net/packagist/v/orisai/scheduler?cache=3600"></a> <a href="https://choosealicense.com/licenses/mpl-2.0/"><img src="https://badgen.net/badge/license/MPL-2.0/blue?cache=3600"></a> <p>

Create script with scheduler setup (e.g. bin/scheduler.php)

use Cron\CronExpression;
use Orisai\Scheduler\SimpleScheduler;

$scheduler = new SimpleScheduler();

// Add jobs
$scheduler->addJob(
	new CallbackJob(fn() => exampleTask()),
	new CronExpression('* * * * *'),
);

$scheduler->run();

Configure crontab to run your script each minute

* * * * * cd path/to/project && php bin/scheduler.php >> /dev/null 2>&1

Looking for more? Documentation is here.