mvaliolahi/scheduler

此包最新版本(v0.0.6)没有提供许可证信息。

命令调度程序。

v0.0.6 2018-02-10 09:37 UTC

This package is auto-updated.

Last update: 2024-09-04 21:08:18 UTC


README

Latest Stable Version Total Downloads Build Status StyleCI PHP-Eye

这是一个框架无关的命令调度程序,可以轻松集成到任何项目中。

    $ composer require mvaliolahi/scheduler`
用法
  1. 创建一个调度程序实例,然后添加一些命令并安排它们。
    
    $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();

*提示:缓存不应为实例。

  1. 使用cron作业在特定时间段内运行$scheduler->start(): * * * * * php /project/schedule:run >> /dev/null 2>&1

提示:调度程序可以使用名为timezone的另一个参数进行配置,该参数将特定时区应用于添加命令,但您可以使用->timezone()方法覆盖它们。

频率
   ->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
待办事项
- add specific class with specific method for trigger instead usual command to scheduler.