teknasyon / crond
Distributed Cron Worker
Installs: 10 781
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- ext-json: *
- dragonmantank/cron-expression: 3.3.*
- psr/log: ^2.0 || ^3.0
Requires (Dev)
- phpunit/phpunit: 9.5.*
README
Distributed Cron Daemon with PHP
Requirements
- PHP 8.0+
- aws/aws-sdk-php
- dragonmantank/cron-expression
- psr/log
Usage
- Set your cron config,
$crons = [ 'my_cron_id1' => [ 'expression' => '* * * * *', 'cmd' => '/usr/bin/php /pathto/myproject/mycron.php', 'lock' => 0 //No need lock ], 'my_cron_id2' => [ 'expression' => '*/10 * * * *', 'cmd' => '/usr/bin/php /pathto/myproject/minutecron.php', 'lock' => 1 ], 'my_cron_id2' => [ 'expression' => '* * * * *', 'cmd' => '/usr/bin/php /pathto/myproject/infinitecron.php' // Like lock:1 ] ]
- Create your Locker class \Teknasyon\Crond\Locker\MemcachedLocker or \Teknasyon\Crond\Locker\RedisLocker
- Create \Teknasyon\Crond\Daemon with cron config and Locker class
<?php use Teknasyon\Crond\Locker\RedisLocker; use Teknasyon\Crond\Daemon; try { $crond = new Daemon($cronConfig, $locker); $crond->setLogger($myPsrLoggerInterfacedObj); $crond->start(); } catch (\Exception $e) { //Error handling } // ...