Giter VIP home page Giter VIP logo

scheduler's Introduction

Command Scheduler

Latest Stable Version Total Downloads Build Status StyleCI PHP-Eye

framework agnostic command scheduler that can be easily integrated with any project.

    $ composer require mvaliolahi/scheduler`
Usage
  1. create an instance of Scheduler then add some command and schedule them.
    
    $scheduler = new Scheduler([
        'cwd' => 'project path | where commands can be run',
        'command_prefix' => 'php specific-cli',
        'cache' => 'an implementation from OverlappinCache Contract'
    ]);
        
    $scheduler->command('rm test.php -fr')
    ->hourly()
    ->when(function()
    {
        return true; // in this situation.
    });
        
        
        $scheduler->start();

*tip: cache should not be instance.

  1. use a cron job to run the $scheduler->start() in a specific period of time.: * * * * * php /project/schedule:run >> /dev/null 2>&1

Tips: Scheduler can be configured using another params named timezone, this parameter apply an specific timezone to add commands but you can overwrite them using ->timezone() method.

Frequencies:
   ->everyMinute();	Run the command every minute
   ->everyFiveMinutes();	Run the command every five minutes
   ->everyTenMinutes();	Run the command every ten minutes
   ->everyFifteenMinutes();	Run the command every fifteen minutes
   ->everyThirtyMinutes();	Run the command every thirty minutes
   ->hourly();	Run the command every hour
   ->hourlyAt(17);	Run the command every hour at 17 mins past the hour
   ->daily();	Run the command every day at midnight
   ->dailyAt('13:00');	Run the command every day at 13:00
   ->twiceDaily(1, 13);	Run the command daily at 1:00 & 13:00
   ->weekly();	Run the command every week
   ->monthly();	Run the command every month
   ->monthlyOn(4, '15:00');	Run the command every month on the 4th at 15:00
   ->quarterly();	Run the command every quarter
   ->yearly();	Run the command every year
   ->timezone('America/New_York');	Set the timezone
   ->weekdays();	Limit the command to weekdays
   ->sundays();	Limit the command to Sunday
   ->mondays();	Limit the command to Monday
   ->tuesdays();	Limit the command to Tuesday
   ->wednesdays();	Limit the command to Wednesday
   ->thursdays();	Limit the command to Thursday
   ->fridays();	Limit the command to Friday
   ->saturdays();	Limit the command to Saturday
   ->between($start, $end);	Limit the command to run between start and end times
   ->when(Closure);	Limit the command based on a truth test
Todo
- add specific class with specific method for trigger instead usual command to scheduler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.