当前位置: 首页>>代码示例>>PHP>>正文


PHP Cron类代码示例

本文整理汇总了PHP中Cron的典型用法代码示例。如果您正苦于以下问题:PHP Cron类的具体用法?PHP Cron怎么用?PHP Cron使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Cron类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Cron类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。