Skip to content

johnroyer/php-job-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-job-runner Build Status

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

About

Simple tool to run routine jobs written in PHP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages