johnroyer / php-job-runner
v1.1.2
2017-05-25 04:05 UTC
Requires
- php: >=5.6
- mtdowling/cron-expression: 1.1.*
Requires (Dev)
- mockery/mockery: ^0.9
- phpunit/phpunit: ^5.7
- psy/psysh: ^0.8
This package is auto-updated.
Last update: 2025-02-28 18:05:45 UTC
README
A simple tool to help you execute routine jobs.
Example
Create a job extends from AbstractJob
:
class Cleanner extends \JobRunner\AbstractJob { private $jobId = 'clean-outdated-backup'; private $runTime = '0 3 * * *'; public function update(\SplSubject $runner) { // clean outdated backups } }
Register your job to runner:
$runner = new JobRunner\Runner(); $runner->attach(new Cleanner); $runner->attach(new SomeOtherJob); // ... $runner->notify(); // runner will notify job which should run at current time
trigger runner by Linux crontab:
$ crontab -e */1 * * * * /usr/bin/php /path/to/bin/runner.php 2>&1 >/dev/null // check jobs every minutes
TODO
there is something to improvent:
- job logger / notifier
- support jobs run only once in a week
- job which will block / conflict other jobs
- better time / routine descreption
License
- MIT license