dawn/crontab 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dawn/crontab

Composer 安装命令:

composer require dawn/crontab

包简介

linux 定时器

README 文档

README

PHP crontab is the implementation of Linux crontab on PHP (essentially still requires crontab as a timing boot driver), the purpose is to facilitate crontab management.

Get Start

Installation

First of all you should require crontab package, is recommend way to install is through Composer:

$ composer require dawn/crontab

Then add linux crontab command to run php crontab

* * * * * /path/to/project && php crontab.php 1>>/dev/null 2>&1

The last you can write crontab job in crontab.php.

Run a job

Crontab manager is manger job, so you can use manager to add a job or remove a job, this is an example.

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
use Crontab\CrontabManager;
$manager = CrontabManager::getInstance();
$manager->add('backup', array(
	'command' => 'ls -al',
	'schedule' => '* * * * *',
	'enable' => true,
	'output' => dirname(__FILE__) . '/log/output.log',
	'error' => dirname(__FILE__) . '/log/error.log',
));
$manager->run();

You can get a crontab and change command or change function

use Crontab\CrontabManager;
$manger = CrontabManager::getInstance()->get('backup');

$manager->setMinute('*/10')
		->setHour('12')
		->setDay('*')
		->setMonth('SEP')
		->setWeek('5L')
		->setCommand('cp back.php ~/index')
		->enable()
		->setOutput('/fixtures/output.txt')
		->setErrorOutput('/fixtures/error.txt')
		->run()

//get output data
$data = $manager->getData();
$error_data = $manager->getErrorData();

you can delete a job you don't want anymore:

$manager->remove('backup');

you can easily to disabled, enabled a crontab to use enable options or enable,disable function.

use Crontab\CrontabManager;

CrontabManager::getInstance()->enable('backup');
CrontabManager::getInstance()->disable('backup');

for more infomation about this project you can read this source code, if you have any problem welcom pull issue/request

License

This project is under MIT License. See the LICENSE file for the full license text.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固