當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CronTask::createTask方法代碼示例

本文整理匯總了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;
 }
開發者ID:sdgdsffdsfff,項目名稱:xcron,代碼行數:20,代碼來源:parser.php

示例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);
開發者ID:sdgdsffdsfff,項目名稱:xcron,代碼行數:10,代碼來源:test_parser.php

示例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);
}
開發者ID:sdgdsffdsfff,項目名稱:xcron,代碼行數:46,代碼來源:test_task.php


注:本文中的CronTask::createTask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。