2017 © Pedro Peláez
 

library php-scheduler

Cron jobs manager

image

azurre/php-scheduler

Cron jobs manager

  • Wednesday, October 5, 2016
  • by a.milenin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

PHP Cron Scheduler Latest Version

Simple cron jobs manager. Keep your project cron jobs in your project!, (*1)

Installation

Require the package with composer:, (*2)

composer require azurre/php-cron-scheduler

Usage

Add scheduler starter to cron:, (*3)

$ crontab -e
* * * * * /usr/bin/php /path/to/project/scheduler.php >> /path/to/project/scheduler.log 2>&1

Sample of scheduler.php, (*4)

$loader = require_once __DIR__ . '/vendor/autoload.php';

use Azurre\Component\Cron\Scheduler;
use Azurre\Component\Cron\Expression;

$e = new Expression();

echo $e->monthly(28); // 0 0 28 * *
echo $e->weekly($e::FRIDAY)->at('05:30'); // 30 5 * * 5
echo $e->daily('06:10'); // 10 6 * * *

echo Expression::create()  // */5 0 16 1 5
    ->setMinute('*/5')
    ->setHour('*')
    ->setDayOfMonth(16)
    ->setDayOfWeek('fri')
    ->setMonth('Jan');

// ------------

$testFunc = function () {
    echo 'TEST OK';
};
$scheduler = new Scheduler();
$scheduler
    ->addJob('* * * * *', function() {
        // just do something
    })->addJob('0 0 * * * *', $testFunc);
$scheduler->run();

// -----------

$logPath = '/path/to/log.log';
$scheduler = new Scheduler('2021-07-05 06:10:00');
$scheduler->addJob($e, function () use($logPath) {
    // run standalone php script
    $cmd = "/usr/bin/php /path/to/script.php >> {$logPath} 2>&1";
    system($cmd);
});
$scheduler->run();

The Versions

05/10 2016

dev-master

9999999-dev https://github.com/azurre/scheduler

Cron jobs manager

  Sources   Download

GPL-3.0

The Requires

 

by Aleksandr Milenin

cron

05/10 2016

v1.1

1.1.0.0 https://github.com/azurre/scheduler

Cron jobs manager

  Sources   Download

ISC

The Requires

 

by Aleksandr Milenin

cron

02/10 2016

v1.0

1.0.0.0 https://github.com/azurre/scheduler

Cron jobs manager

  Sources   Download

ISC

The Requires

 

by Aleksandr Milenin

cron