Beispiel #1
0
 function exec($cron_id)
 {
     $this->begin('index.php?app=system&ctl=admin_crontab&act=index');
     $model = app::get('base')->model('crontab');
     $cron = $model->getRow('id', array('id' => $cron_id));
     if (!$cron || base_crontab_schedule::trigger_one($cron['id']) === false) {
         $this->end(false, '执行失败');
     }
     $this->end(true, '执行成功');
 }
Beispiel #2
0
#!/usr/bin/env php
<?php 
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2012 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
error_reporting(E_ALL ^ E_NOTICE);
$root_dir = realpath(dirname(__FILE__) . '/../../');
$script_dir = $root_dir . '/script';
// 修改默认的config配置
define('LOG_LEVEL', LOG_INFO);
define('LOG_TYPE', 3);
define('LOG_FILE', $root_dir . '/data/logs/crontab/{date}.php');
//-------------------------------------------------------------------------------------
require_once $script_dir . "/lib/runtime.php";
set_error_handler('error_handler');
//-------------------------------------------------------------------------------------
base_crontab_schedule::trigger_all();
//-------------------------------------------------------------------------------------
function error_handler($code, $msg, $file, $line)
{
    if ($code == ($code & (E_ERROR ^ E_USER_ERROR ^ E_USER_WARNING))) {
        logger::error(sprintf('ERROR:%d @ %s @ file:%s @ line:%d', $code, $msg, $file, $line));
        if ($code == ($code & (E_ERROR ^ E_USER_ERROR))) {
            exit;
        }
    }
    return true;
}
Beispiel #3
0
 function command_exec()
 {
     //kernel::single('base_misc_autotask')->trigger();
     base_crontab_schedule::trigger_all();
 }
Beispiel #4
0
 function command_crontabexec()
 {
     $crontab = func_get_args();
     if (count($crontab) !== 1) {
         logger::info('usage: php cmd crontabexec <crontab_name>');
         exit;
     }
     $cron_id = $crontab[0];
     if (base_crontab_schedule::is_valid_cronentry($cron_id) === false) {
         logger::info('cron: ' . $cron_id . ' not fond');
         exit;
     }
     base_crontab_schedule::run_task($cron_id);
     exit;
 }