本文整理汇总了PHP中cron::all方法的典型用法代码示例。如果您正苦于以下问题:PHP cron::all方法的具体用法?PHP cron::all怎么用?PHP cron::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cron
的用法示例。
在下文中一共展示了cron::all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
<?php
$crons = cron::all();
foreach ($crons as $cron) {
$c = new Cron\CronExpression($cron->getSchedule(), new Cron\FieldFactory());
try {
$c->getNextRunDate();
} catch (Exception $ex) {
$cron->remove();
}
}
示例2: foreach
<?php
foreach (cron::all() as $cron) {
if ($cron->getFunction() == 'cronPlugin' && $cron->getClass() == '') {
$cron->remove();
}
if ($cron->getFunction() == 'cronCore' && $cron->getClass() == '') {
$cron->remove();
}
if ($cron->getFunction() == 'historize' && $cron->getClass() == 'history') {
$cron->setTimeout(5);
$cron->save();
}
if ($cron->getFunction() == 'archive' && $cron->getClass() == 'history') {
$cron->setTimeout(20);
$cron->save();
}
if ($cron->getFunction() == 'check' && $cron->getClass() == 'scenario') {
$cron->setTimeout(5);
$cron->save();
}
if ($cron->getFunction() == 'collect' && $cron->getClass() == 'cmd') {
$cron->setTimeout(5);
$cron->save();
}
}
$cron = new cron();
$cron->setClass('jeedom');
$cron->setFunction('persist');
$cron->setSchedule('* * * * * *');
$cron->setTimeout(5);
示例3: cron
public static function cron()
{
if (!self::isStarted()) {
config::save('enableScenario', 1);
config::save('enableCron', 1);
$cache = cache::byKey('jeedom::usbMapping');
$cache->remove();
foreach (cron::all() as $cron) {
if ($cron->running() && $cron->getClass() != 'jeedom' && $cron->getFunction() != 'cron') {
try {
$cron->halt();
} catch (Exception $e) {
}
}
}
try {
jeedom::start();
} catch (Exception $e) {
}
try {
plugin::start();
} catch (Exception $e) {
}
touch('/tmp/jeedom_start');
self::event('start');
log::add('core', 'info', 'Démarrage de Jeedom OK');
}
self::isDateOk();
try {
$c = new Cron\CronExpression(config::byKey('update::check'), new Cron\FieldFactory());
if ($c->isDue()) {
$lastCheck = strtotime(config::byKey('update::lastCheck'));
if (strtotime('now') - $lastCheck > 3600) {
if (config::byKey('update::auto') == 1) {
update::checkAllUpdate();
jeedom::update('', 0);
} else {
config::save('update::check', rand(1, 59) . ' ' . rand(6, 7) . ' * * *');
update::checkAllUpdate();
$updates = update::byStatus('update');
if (count($updates) > 0) {
$toUpdate = '';
foreach ($updates as $update) {
$toUpdate .= $update->getLogicalId() . ',';
}
message::add('update', __('De nouvelles mises à jour sont disponibles : ', __FILE__) . trim($toUpdate, ','), '', 'newUpdate');
}
}
}
}
$c = new Cron\CronExpression('35 00 * * 0', new Cron\FieldFactory());
if ($c->isDue()) {
cache::clean();
DB::optimize();
}
$c = new Cron\CronExpression('02 02 * * *', new Cron\FieldFactory());
if ($c->isDue()) {
try {
log::chunk();
cron::clean();
} catch (Exception $e) {
log::add('log', 'error', $e->getMessage());
}
}
$c = new Cron\CronExpression('21 23 * * *', new Cron\FieldFactory());
if ($c->isDue()) {
try {
scenario::cleanTable();
user::cleanOutdatedUser();
scenario::consystencyCheck();
} catch (Exception $e) {
log::add('scenario', 'error', $e->getMessage());
}
}
} catch (Exception $e) {
}
}
示例4: init
}
if (init('action') == 'save') {
utils::processJsonObject('cron', init('crons'));
ajax::success();
}
if (init('action') == 'remove') {
$cron = cron::byId(init('id'));
if (!is_object($cron)) {
throw new Exception(__('Cron id inconnu', __FILE__));
}
$cron->remove();
ajax::success();
}
if (init('action') == 'all') {
$results = array();
$results['crons'] = utils::o2a(cron::all(true));
$results['nbCronRun'] = cron::nbCronRun();
$results['nbProcess'] = cron::nbProcess();
$results['nbMasterCronRun'] = cron::jeeCronRun() ? 1 : 0;
$results['loadAvg'] = cron::loadAvg();
ajax::success($results);
}
if (init('action') == 'start') {
$cron = cron::byId(init('id'));
if (!is_object($cron)) {
throw new Exception(__('Cron id inconnu', __FILE__));
}
$cron->run();
sleep(1);
ajax::success();
}