本文整理汇总了PHP中CronTask::createTask方法的典型用法代码示例。如果您正苦于以下问题:PHP CronTask::createTask方法的具体用法?PHP CronTask::createTask怎么用?PHP CronTask::createTask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CronTask
的用法示例。
在下文中一共展示了CronTask::createTask方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
public static function parse($file)
{
/*{{{*/
if (!file_exists($file) || filesize($file) === 0) {
return false;
}
$data = json_decode(file_get_contents($file), true);
self::$check_sum = md5(json_encode($data));
if (empty($data)) {
return array();
}
$execute_plan = array();
foreach ($data as $task) {
$task = CronTask::createTask($task['task'], $task['user'], $task['id'], $task['running_user']);
if ($task) {
$execute_plan[] = $task;
}
}
return $execute_plan;
}
示例2:
<?php
include '../src/parser.php';
include '../src/task.php';
include '../src/date.php';
include '../src/exception.php';
include '../src/logger.php';
$task = "0 10 * * 2 (/usr/bin/lockf -t 0 /home/q/system/cloudopenapi/logs/clean.lock /usr/local/php/bin/php /home/q/system/cloudopenapi/src/task/tool/clean_expired_data.php) >> /dev/null 2>&1 &";
$task = CronTask::createTask($task, null, null, null);
print_r($task);
示例3: test_area_plan
function test_area_plan()
{
/*{{{*/
$rule = '*/5 10-21 * * * echo 1';
$date = new CronSimpleDate(strtotime('2013/03/31 2:05:00'));
$task = CronTask::createTask($rule, $date);
$date = new CronSimpleDate(strtotime('2013/03/31 11:05:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/31 4:10:00'));
assert(!$task->isReady($date));
$date = new CronSimpleDate(strtotime('2013/03/31 11:14:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/31 11:19:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/31 11:23:00'));
assert(!$task->isReady($date));
$date = new CronSimpleDate(strtotime('2013/03/31 11:24:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/04/2 11:23:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/31 22:19:00'));
assert(!$task->isReady($date));
$rule = '* * 4-6 * * echo 1';
$date = new CronSimpleDate(strtotime('2013/03/03 1:10:11'));
$task = CronTask::createTask($rule, $date);
$date = new CronSimpleDate(strtotime('2013/03/03 1:11:00'));
assert(!$task->isReady($date));
$date = new CronSimpleDate(strtotime('2013/03/04 1:11:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/07 1:11:00'));
assert(!$task->isReady($date));
$rule = '4-5 * * * * echo 1';
$task = CronTask::createTask($rule);
$date = new CronSimpleDate(strtotime('2013/03/03 1:4:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
$date = new CronSimpleDate(strtotime('2013/03/03 1:5:00'));
assert($task->isReady($date));
$task->setIsRunning($date);
}