定制 battis/autocrontabjob 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

battis/autocrontabjob

最新稳定版本:v1.0.1

Composer 安装命令:

composer require battis/autocrontabjob

包简介

An object-oriented approach to scheduling regular cron jobs automatically

README 文档

README

Latest Version Scrutinizer Code Quality

An object-oriented approach to scheduling regular cron jobs automatically

Install

Include in your composer.json:

"require": {
  "battis/autocrontabjob": "~1.0"
}

Use

This object requires a bit of prior preparation before use:

  1. Extend the abstract Battis\AutoCrontabJob class and implement the abstract scheduledJob() method.
  2. Create a script that will be run regularly as a Cron job, that instantiates your class and calls its scheduledJob() method.

Gotcha warning: Remember that, when a script is run by cron, it is not run by Apache, so it will not generate output to the Apache log files. Handily, there is a log built-in that you can use (see below). By default, the log will be generated in the same directory as the script and be similarly named (.log instead of .php).

A sample script file (which is an all-in-one, also extending the abstract class), called MyJob.php:

<?php

require_once('vendor/autoload.php');

// extend the abstract class with our own scheduledJob() method
class MyJob extends Battis\AutoCrontabJob {

	public function scheduledJob() {
		$this->log->log('I did something!');
	}
}

// instantiate our class
$job = new MyJob(
	'example',
	__FILE__, // *this* file will be called by crontab
	'*/5 * * * *' // run every five minutes (woo hoo!)
);

// fire the scheduledJob() method
$job->scheduledJob();

?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2015-08-11