本文整理汇总了PHP中Cron类的典型用法代码示例。如果您正苦于以下问题:PHP Cron类的具体用法?PHP Cron怎么用?PHP Cron使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cron类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testGetNextWithTimestamp
public function testGetNextWithTimestamp()
{
$tz = new DateTimezone('Europe/Berlin');
$dt = new DateTime('2014-12-31 23:42', $tz);
$cron = new Cron('45 9 29 feb thu', $tz);
$this->assertEquals(1709196300, $cron->getNext($dt->getTimestamp()));
}
开发者ID:poliander,项目名称:cron,代码行数:7,代码来源:CronTest.php
示例2: run
/**
* Entry point for the back ground worker
*/
public static function run()
{
$notifications = new Notifications();
$subscriptions = new Subscriptions();
$cron = new Cron($notifications, $subscriptions);
$cron->pushNotifications();
}
开发者ID:evaluation-alex,项目名称:web_hooks,代码行数:10,代码来源:cron.php
示例3: activate
/**
* Activate WP Currencies.
*
* What happens when WP Currencies is activated.
*
* @since 1.4.0
*/
public static function activate()
{
self::create_tables();
$cron = new Cron();
$cron->schedule_updates();
do_action('wp_currencies_activated');
}
开发者ID:nekojira,项目名称:wp-currencies,代码行数:14,代码来源:install.php
示例4: testIsValidFor
/**
* @dataProvider isValidForProvider
* @param int $time
* @param string $expression
* @param bool $expectedResult
*/
public function testIsValidFor($time, $expression, $expectedResult)
{
$eventMock = $this->getMock('Magento\\Framework\\Event', [], [], '', false);
$this->cron->setCronExpr($expression);
$this->cron->setNow($time);
$this->assertEquals($expectedResult, $this->cron->isValidFor($eventMock));
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例5: run
function run($config)
{
$this->setConfig($config);
$this->setDbAdapter();
$this->setView();
$this->setInit();
$cron = new Cron($this->registry);
$cron->index();
}
开发者ID:norayrx,项目名称:otms,代码行数:9,代码来源:CronPreload.php
示例6: poorMansCron
static function poorMansCron()
{
$intervals = array("minute", "five", "fifteen", "hour", "week");
foreach ($intervals as $interval) {
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if (!$entity) {
$entity = new Cron();
$entity->interval = $interval;
$entity->save();
}
Cron::run($interval, false);
}
return;
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:14,代码来源:Init.php
示例7: run
static function run($interval, $ignore_last_run = true)
{
$phpbin = PHP_BINDIR . "/php";
if ($ignore_last_run) {
shell_exec('echo $phpbin -q ' . SITEPATH . 'cron/' . $interval . '.php | at now');
return;
}
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if (!$entity) {
$entity = new Cron();
$entity->interval = $interval;
$entity->save();
}
$last_ran = $entity->last_ran;
if (!$last_ran) {
$last_ran = 0;
}
switch ($interval) {
case "minute":
$seconds = 60;
break;
case "five":
$seconds = 60 * 5;
break;
case "fifteen":
$seconds = 60 * 15;
break;
case "hour":
$seconds = 60 * 60;
break;
case "week":
default:
$seconds = 60 * 60 * 24 * 7;
break;
}
$time = time();
if ($time > $last_ran + $seconds) {
$shell = $phpbin . ' -q ' . SITEPATH . 'cron/' . $interval . '.php > /dev/null 2>/dev/null &';
shell_exec($shell);
$last_ran = $time;
$entity = getEntity(array("type" => "Cron", "metadata_name" => "interval", "metadata_value" => $interval));
if ($entity) {
$entity->last_ran = $last_ran;
$entity->save();
}
}
return;
}
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:48,代码来源:Cron.php
示例8: initialize
/**
*
* Initializes configs for the APP to run
*/
public static function initialize()
{
/**
* Load all the configs from DB
*/
//Change the default cache system, based on your config /config/cache.php
Cache::$default = Core::config('cache.default');
//is not loaded yet in Kohana::$config
Kohana::$config->attach(new ConfigDB(), FALSE);
//overwrite default Kohana init configs.
Kohana::$base_url = Core::config('general.base_url');
//enables friendly url @todo from config
Kohana::$index_file = FALSE;
//cookie salt for the app
Cookie::$salt = Core::config('auth.cookie_salt');
/* if (empty(Cookie::$salt)) {
// @TODO missing cookie salt : add warning message
} */
// -- i18n Configuration and initialization -----------------------------------------
I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset'));
//Loading the OC Routes
// if (($init_routes = Kohana::find_file('config','routes')))
// require_once $init_routes[0];//returns array of files but we need only 1 file
//faster loading
require_once APPPATH . 'config/routes.php';
//getting the selected theme, and loading options
Theme::initialize();
//run crontab
if (core::config('general.cron') == TRUE) {
Cron::run();
}
}
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:36,代码来源:core.php
示例9: run
function run()
{
global $ost;
Cron::run();
$ost->logDebug('Cron Job', 'Cron job executed [' . $_SERVER['REMOTE_ADDR'] . ']');
$this->response(200, 'Completed');
}
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:7,代码来源:api.cron.php
示例10: initialize
/**
*
* Initializes configs for the APP to run
*/
public static function initialize()
{
//enables friendly url
Kohana::$index_file = FALSE;
//temporary cookie salt in case of exception
Cookie::$salt = 'cookie_oc_temp';
//Change the default cache system, based on your config /config/cache.php
Cache::$default = Core::config('cache.default');
//loading configs from table config
//is not loaded yet in Kohana::$config
Kohana::$config->attach(new ConfigDB(), FALSE);
//overwrite default Kohana init configs.
Kohana::$base_url = Core::config('general.base_url');
//cookie salt for the app
Cookie::$salt = Core::config('auth.cookie_salt');
// i18n Configuration and initialization
I18n::initialize(Core::config('i18n.locale'), Core::config('i18n.charset'));
//Loading the OC Routes
require_once APPPATH . 'config/routes.php';
//getting the selected theme, and loading options
Theme::initialize();
//run crontab
if (core::config('general.cron') == TRUE) {
Cron::run();
}
}
开发者ID:ThomWensink,项目名称:common,代码行数:30,代码来源:core.php
示例11: __construct
public function __construct()
{
parent::__construct();
$this->chmod();
echo '<br />' . t('Done!') . '<br />';
echo t('The Jobs Cron is working to complete successfully!');
}
开发者ID:nsrau,项目名称:pH7-Social-Dating-CMS,代码行数:7,代码来源:GeneralCoreCron.php
示例12: actionUpdate
public function actionUpdate($id)
{
$form = new TestForm();
if ($form->load($_POST)) {
$test = Test::findOne($id);
//Confere se usuário tem permissão para editar teste na origem OU no destino
$source = $test->getSourceDomain()->one();
$destination = $test->getDestinationDomain()->one();
$permission = false;
if ($source && RbacController::can('test/delete', $source->name)) {
$permission = true;
}
if ($destination && RbacController::can('test/delete', $destination->name)) {
$permission = true;
}
if (!$permission) {
Yii::$app->getSession()->addFlash("warning", Yii::t("circuits", "You are not allowed to update a automated test involving these selected domains"));
return false;
}
$cron = Cron::findOneTestTask($id);
$cron->freq = $form->cron_value;
$cron->status = Cron::STATUS_PROCESSING;
if ($cron->save()) {
Yii::$app->getSession()->addFlash("success", Yii::t("circuits", "Automated Test updated successfully"));
return true;
}
}
return false;
}
开发者ID:ufrgs-hyman,项目名称:meican,代码行数:29,代码来源:ManagerController.php
示例13: run
function run()
{
//called by outside cron NOT autocron
Cron::MailFetcher();
Cron::TicketMonitor();
cron::PurgeLogs();
}
开发者ID:supaket,项目名称:helpdesk,代码行数:7,代码来源:class.cron.php
示例14: init
public static function init()
{
if (!isset($_GET['cronTok'])) {
return;
}
define('EDUCASK_ROOT', dirname(getcwd()));
require_once EDUCASK_ROOT . '/core/classes/Bootstrap.php';
Bootstrap::registerAutoloader();
$database = Database::getInstance();
$database->connect();
if (!$database->isConnected()) {
return;
}
Bootstrap::initializePlugins();
$cron = new Cron($_GET['cronTok']);
$cron->run();
}
开发者ID:educask,项目名称:EducaskCore,代码行数:17,代码来源:cron.php
示例15: __construct
public function __construct()
{
if (isset(self::$current)) {
throw new ConstructionException('Cannot construct more than one instance of singleton class Cron.');
}
$this->_parse_arguments();
self::$current = $this;
}
开发者ID:NateBrune,项目名称:bithub,代码行数:8,代码来源:Cron.lib.php
示例16: osc_runAlert
function osc_runAlert($type = null, $last_exec = null)
{
if (!in_array($type, array('HOURLY', 'DAILY', 'WEEKLY', 'INSTANT'))) {
return;
}
if ($last_exec == null) {
$cron = Cron::newInstance()->getCronByType($type);
if (is_array($cron)) {
$last_exec = $cron['d_last_exec'];
} else {
$last_exec = '0000-00-00 00:00:00';
}
}
$internal_name = 'alert_email_hourly';
switch ($type) {
case 'HOURLY':
$internal_name = 'alert_email_hourly';
break;
case 'DAILY':
$internal_name = 'alert_email_daily';
break;
case 'WEEKLY':
$internal_name = 'alert_email_weekly';
break;
case 'INSTANT':
$internal_name = 'alert_email_instant';
break;
}
$active = TRUE;
$searches = Alerts::newInstance()->findByTypeGroup($type, $active);
foreach ($searches as $s_search) {
// Get if there're new ads on this search
$json = $s_search['s_search'];
$array_conditions = (array) json_decode($json);
$new_search = Search::newInstance();
$new_search->setJsonAlert($array_conditions);
$new_search->addConditions(sprintf(" %st_item.dt_pub_date > '%s' ", DB_TABLE_PREFIX, $last_exec));
$items = $new_search->doSearch();
$totalItems = $new_search->count();
if (count($items) > 0) {
// If we have new items from last check
// Catch the user subscribed to this search
$users = Alerts::newInstance()->findUsersBySearchAndType($s_search['s_search'], $type, $active);
if (count($users) > 0) {
$ads = '';
foreach ($items as $item) {
$ads .= '<a href="' . osc_item_url_ns($item['pk_i_id']) . '">' . $item['s_title'] . '</a><br/>';
}
foreach ($users as $user) {
osc_run_hook('hook_' . $internal_name, $user, $ads, $s_search, $items, $totalItems);
AlertsStats::newInstance()->increase(date('Y-m-d'));
}
}
}
}
}
开发者ID:oanav,项目名称:closetshare,代码行数:56,代码来源:alerts.php
示例17: start
static function start()
{
if (!Lock::isOn('cron-running-' . $_ENV['projectName'])) {
if (Lock::on('cron-running-' . $_ENV['projectName'])) {
Debug::out('Starting');
Control::req('scripts/crons/config');
while (!Lock::isOn('cron-off-' . $_ENV['projectName'])) {
$time = new Time();
//+ ensure running only every minute {
$parseTime = $time->format('YmdHi');
if (self::$lastParsedTime == $parseTime) {
sleep(2);
continue;
}
self::$lastParsedTime = $parseTime;
//+ }
//+ execute run items {
$run = self::getRun($time);
foreach ($run as $i) {
$item = self::$list[$i];
if (self::$running[$i]) {
$pid = pcntl_waitpid(self::$running[$i], $status, WNOHANG);
if ($pid == 0) {
//process is currently running, don't run again
continue;
} elseif ($pid == -1) {
Debug::out('Process error:', $item);
continue;
}
}
$pid = pcntl_fork();
if ($pid == -1) {
Debug::quit('Could not fork process', $item);
} elseif ($pid) {
//this is the parent
self::$running[$i] = $pid;
} else {
//this is the child
self::$args = $item[2];
$script = Config::userFileLocation($item[1], 'control/scripts/crons');
Control::req($script);
exit;
}
}
//+ }
}
Lock::off('cron-running-' . $_ENV['projectName']);
} else {
Debug::quit('Failed to lock "cron-running"');
}
} else {
Debug::quit('Cron already running');
}
}
开发者ID:jstacoder,项目名称:brushfire,代码行数:54,代码来源:Cron.php
示例18: __construct
public function __construct()
{
$this->config = parse_ini_file(__DOCROOT__ . '/config.ini', true);
Cron::$database_connect = mysql_connect($this->config['database']['host'], $this->config['database']['user'], $this->config['database']['password']);
if (!Cron::$database_connect) {
echo "Unable to connect to DB: " . mysql_error(Cron::$database_connect);
exit;
}
mysql_query("SET NAMES 'UTF8'", Cron::$database_connect);
if (!mysql_select_db($this->config['database']['name'], Cron::$database_connect)) {
echo "Unable to select mydbname: " . mysql_error(Cron::$database_connect);
exit;
}
}
开发者ID:heshuai64,项目名称:ebo,代码行数:14,代码来源:Cron.php
示例19: boot
public function boot()
{
// Please note the different namespace
// and please add a \ in front of your classes in the global namespace
\Event::listen('cron.collectJobs', function () {
\Cron::add('example1', '* * * * *', function () {
$this->index();
return 'No';
});
\Cron::add('example2', '*/2 * * * *', function () {
// Do some crazy things successfully every two minute
return null;
});
\Cron::add('disabled job', '0 * * * *', function () {
// Do some crazy things successfully every hour
}, false);
});
}
开发者ID:MehmetNuri,项目名称:faveo-helpdesk,代码行数:18,代码来源:AppServiceProvider.php
示例20: run
/**
* @see CronInterface::run()
*/
public static function run()
{
if (self::check() == true) {
$last_run_daily_datetime = Registry::get_value("base_cron_last_run_daily_datetime");
$last_run_weekly_datetime = Registry::get_value("base_cron_last_run_weekly_datetime");
$last_run_daily_datetime_handler = new DatetimeHandler($last_run_daily_datetime);
$last_run_weekly_datetime_handler = new DatetimeHandler($last_run_weekly_datetime);
$current_datetime_handler = new DatetimeHandler(date("Y-m-d H:i:s"));
if ($last_run_daily_datetime_handler->distance($current_datetime_handler) >= 86400) {
$daily = true;
} else {
$daily = false;
}
if ($last_run_weekly_datetime_handler->distance($current_datetime_handler) >= 604800) {
$weekly = true;
} else {
$weekly = false;
}
$cron_event = new CronEvent(self::$last_run_id, $daily, $weekly);
$event_handler = new EventHandler($cron_event);
if ($event_handler->get_success() == true) {
if (self::$last_run_id + 1 > 256) {
Registry::set_value("base_cron_last_run_id", 1);
self::$last_run_id = 1;
} else {
Registry::set_value("base_cron_last_run_id", self::$last_run_id + 1);
self::$last_run_id = self::$last_run_id + 1;
}
Registry::set_value("base_cron_last_run_datetime", date("Y-m-d H:i:s"));
self::$last_run_datetime = date("Y-m-d H:i:s");
if ($daily == true) {
Registry::set_value("base_cron_last_run_daily_datetime", date("Y-m-d H:i:s"));
}
if ($weekly == true) {
Registry::set_value("base_cron_last_run_weekly_datetime", date("Y-m-d H:i:s"));
}
}
}
}
开发者ID:suxinde2009,项目名称:www,代码行数:42,代码来源:cron.class.php
注:本文中的Cron类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论